From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mx.groups.io with SMTP id smtpd.web08.29243.1607915605269553867 for ; Sun, 13 Dec 2020 19:13:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.191, mailfrom: xiewenyi2@huawei.com) Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CvRK036KHzM4Xw; Mon, 14 Dec 2020 11:12:36 +0800 (CST) Received: from HGH1000039998.huawei.com (10.184.68.188) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Mon, 14 Dec 2020 11:13:13 +0800 From: "wenyi,xie" To: , , , CC: , Subject: [PATCH EDK2 v1 1/1] BaseTools/GenFfs: Optimazing else if statement Date: Mon, 14 Dec 2020 11:11:29 +0800 Message-ID: <1607915489-70490-2-git-send-email-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1607915489-70490-1-git-send-email-xiewenyi2@huawei.com> References: <1607915489-70490-1-git-send-email-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.184.68.188] X-CFilter-Loop: Reflected Content-Type: text/plain When Alignment < 0x400 is false, the expression of Alignment >= 0x400 is always true. So extract the expression from the else if statement. Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Signed-off-by: Wenyi Xie --- BaseTools/Source/C/GenFfs/GenFfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c index fcb911f4fc34..70538b138f33 100644 --- a/BaseTools/Source/C/GenFfs/GenFfs.c +++ b/BaseTools/Source/C/GenFfs/GenFfs.c @@ -821,12 +821,11 @@ Returns: if (Alignment < 0x400){ sprintf (AlignmentBuffer, "%d", Alignment); } - else if (Alignment >= 0x400) { - if (Alignment >= 0x100000) { + else if (Alignment >= 0x100000) { sprintf (AlignmentBuffer, "%dM", Alignment/0x100000); - } else { + } + else { sprintf (AlignmentBuffer, "%dK", Alignment/0x400); - } } Status = StringtoAlignment (AlignmentBuffer, &(InputFileAlign[InputFileNum])); } -- 2.20.1.windows.1