REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1249

We found potential dead codes within File.c during the code coverage test.

After manual review, we think the below ones are positive reports:

A. In function MangleFileName():

  FileName = TrimString (FileName);
  // Begin of dead codes
  if (*FileName == L'\0') {
    goto Exit;
  }
  // End of dead codes

When the code reaches the TrimString() call, the string in 'FileName' is
guaranteed to have a '\' character due to the call patterns of
MangleFileName(). So after trimming the lead-off/tailing white spaces,
string in 'FileName' will not be an empty string.

B. In function MangleFileName():

  if (FileName[0] == L'.') {
    if (FileName[1] == L'.') {
      if (FileName[2] == L'\0') {
        goto Exit;
      } else {
        FileName += 2;
      }
    } else if (FileName[1] == L'\0') {
      goto Exit;
    }
  }

When the code hits the above checks, string in 'FileName' will always have
a leading '\' character (denoting an absolute path) due to the call
patterns of MangleFileName(). So no leading '.' can be there in string
'FileName'.

This commit will remove those dead codes.

Cc: Paulo Alcantara <[email protected]>
Cc: Ruiyu Ni <[email protected]>
Cc: Star Zeng <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <[email protected]>
---
 MdeModulePkg/Universal/Disk/UdfDxe/FileName.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c 
b/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c
index 36551a4dba..18549e4e45 100644
--- a/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c
+++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c
@@ -128,9 +128,6 @@ MangleFileName (
   }
 
   FileName = TrimString (FileName);
-  if (*FileName == L'\0') {
-    goto Exit;
-  }
 
   if ((StrLen (FileName) > 1) && (FileName[StrLen (FileName) - 1] == L'\\')) {
     FileName[StrLen (FileName) - 1] = L'\0';
@@ -138,18 +135,6 @@ MangleFileName (
 
   FileNameSavedPointer = FileName;
 
-  if (FileName[0] == L'.') {
-    if (FileName[1] == L'.') {
-      if (FileName[2] == L'\0') {
-        goto Exit;
-      } else {
-        FileName += 2;
-      }
-    } else if (FileName[1] == L'\0') {
-      goto Exit;
-    }
-  }
-
   while (*FileName != L'\0') {
     if (*FileName == L'\\') {
       FileName = ExcludeTrailingBackslashes (FileName);
-- 
2.12.0.windows.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to