From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 81BEA2194D3B9 for ; Sun, 14 Oct 2018 21:55:33 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2018 21:55:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,383,1534834800"; d="scan'208";a="78773956" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.9]) by fmsmga008.fm.intel.com with ESMTP; 14 Oct 2018 21:55:32 -0700 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Paulo Alcantara , Ruiyu Ni , Star Zeng Date: Mon, 15 Oct 2018 12:55:21 +0800 Message-Id: <20181015045522.18732-7-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20181015045522.18732-1-hao.a.wu@intel.com> References: <20181015045522.18732-1-hao.a.wu@intel.com> Subject: [PATCH v1 6/7] MdeModulePkg/UdfDxe: Remove dead codes in FileName.c X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2018 04:55:33 -0000 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 Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu --- 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