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

Bob Feng bob.c.feng at intel.com
Tue Dec 15 04:02:07 UTC 2020


This change makes sense.

Please replace the tab with the space in this patch.
You may need to check your patch with BaseTools\Scripts\PatchCheck.py script before sending the patch review.

Thanks,
Bob

-----Original Message-----
From: Wenyi Xie <xiewenyi2 at huawei.com> 
Sent: Monday, December 14, 2020 11:11 AM
To: devel at edk2.groups.io; Feng, Bob C <bob.c.feng at intel.com>; gaoliming at byosoft.com.cn; Chen, Christine <yuwei.chen at intel.com>
Cc: songdongkuang at huawei.com; xiewenyi2 at huawei.com
Subject: [PATCH EDK2 v1 1/1] BaseTools/GenFfs: Optimazing else if statement

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 (#68836): https://edk2.groups.io/g/devel/message/68836
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