From 31c295e71aafed85c75a772dabf6e5e09d2f4a60 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Thu, 30 Nov 2017 14:42:05 +0800 Subject: [PATCH] BaseTools/EfiRom: Refine the logic in main() This commit refines the logic for main(). It makes the logic more straightforward to prevent possible mis-reports by static code checkers. Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Liming Gao --- BaseTools/Source/C/EfiRom/EfiRom.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c b/BaseTools/Source/C/EfiRom/EfiRom.c index 0f89280251..6648f4c738 100644 --- a/BaseTools/Source/C/EfiRom/EfiRom.c +++ b/BaseTools/Source/C/EfiRom/EfiRom.c @@ -101,11 +101,13 @@ Returns: // Find the last . on the line and replace the filename extension with // the default // - for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1; - (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\'); - Ext-- - ) - ; + Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1; + while (Ext >= mOptions.OutFileName) { + if ((*Ext == '.') || (*Ext == '\\')) { + break; + } + Ext--; + } // // If dot here, then insert extension here, otherwise append //