[edk2-devel] [PATCH EDK2 v1 1/1] BaseTools/GenFfs: Optimazing else if statement

wenyi,xie via groups.io xiewenyi2=huawei.com at groups.io
Mon Dec 14 03:11:29 UTC 2020


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 <bob.c.feng at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen at intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2 at huawei.com>
---
 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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#68756): https://edk2.groups.io/g/devel/message/68756
Mute This Topic: https://groups.io/mt/78943291/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list