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.31; helo=mga06.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 BCA2A211799CC for ; Tue, 16 Oct 2018 00:50:49 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 00:50:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,387,1534834800"; d="scan'208";a="100607028" Received: from shzintpr01.sh.intel.com (HELO [10.7.209.21]) ([10.239.4.80]) by orsmga002.jf.intel.com with ESMTP; 16 Oct 2018 00:50:48 -0700 To: Hao Wu , edk2-devel@lists.01.org Cc: Ruiyu Ni , star.zeng@intel.com References: <20181015045522.18732-1-hao.a.wu@intel.com> <20181015045522.18732-8-hao.a.wu@intel.com> From: "Zeng, Star" Message-ID: Date: Tue, 16 Oct 2018 15:50:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Subject: Re: [PATCH v1 7/7] MdeModulePkg/UdfDxe: Handle dead codes in FileSystemOperations.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: Tue, 16 Oct 2018 07:50:49 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit On 2018/10/16 14:59, Zeng, Star wrote: > On 2018/10/15 12:55, Hao Wu wrote: >> 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. For function GetAllocationDescriptor(): >> Due to the all the calling places for this function, the input parameter >> 'RecordingFlags' can only with value 'LongAdsSequence' or >> 'ShortAdsSequence'. >> >> So the below code will never be reached: >> >>    return EFI_DEVICE_ERROR; >> >> This commit will add "ASSERT (FALSE);" before the above line to indicate >> this. >> >> B. For function GetAllocationDescriptorLsn(): >> Due to the all the calling places for this function, the input parameter >> 'RecordingFlags' can only with value 'LongAdsSequence' or >> 'ShortAdsSequence'. >> >> So the below code will never be reached: >> >>    return EFI_UNSUPPORTED; >> >> This commit will add "ASSERT (FALSE);" before the above line to indicate >> this. >> >> C. For function SetFileInfo(): >> Due to the all the calling places for this function, the input parameter >> 'FileName' will never be a NULL pointer. >> >> So the below codes will never be reached: >> >>    } else { >>      FileInfo->FileName[0] = '\0'; >>    } >> >> This commit will add "ASSERT (FALSE);" before the above lines to indicate >> this. > > Hao, > > Thanks for the patch. > > I think we should see what is the expected value for the parameter, but > not see how caller uses the parameter. > From this point of view, I think the C case is valid and may be no need > to change. More information about the C case. There are two places in the function to handle FileName == NULL, but this patch only updates one place. If the patch wants to forbid the function to accept FileName == NULL, it should update those two places and update function description at the same time. Otherwise keep the function no change. Thanks, Star > > > Thanks, > Star > >> >> 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/FileSystemOperations.c | 12 >> ++++++++++++ >>   1 file changed, 12 insertions(+) >> >> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c >> b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c >> index 1400846bf1..19acd0554c 100644 >> --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c >> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c >> @@ -738,6 +738,10 @@ GetAllocationDescriptor ( >>         ); >>     } >> +  // >> +  // Code should never reach here. >> +  // >> +  ASSERT (FALSE); >>     return EFI_DEVICE_ERROR; >>   } >> @@ -784,6 +788,10 @@ GetAllocationDescriptorLsn ( >>       return EFI_SUCCESS; >>     } >> +  // >> +  // Code should never reach here. >> +  // >> +  ASSERT (FALSE); >>     return EFI_UNSUPPORTED; >>   } >> @@ -2413,6 +2421,10 @@ SetFileInfo ( >>     if (FileName != NULL) { >>       StrCpyS (FileInfo->FileName, StrLen (FileName) + 1, FileName); >>     } else { >> +    // >> +    // Code should never reach here. >> +    // >> +    ASSERT (FALSE); >>       FileInfo->FileName[0] = '\0'; >>     } >>