On 09/13/17 08:43, Zeng, Star wrote:
> Beyond the Rb (I do not want to block this patch series), I am curious about 
> one question.
> 
> There may be more this kind of workarounds to fix the build failure.
> Is it possible to disable the warning (like below example for VS) for 
> specific version of GCC for this kind of false alarm?
> 
> 
> ProcessorBind.h:
> #if defined(_MSC_EXTENSIONS)
> 
> ...
> 
> #if _MSC_VER == 1800 || _MSC_VER == 1900
> 
> //
> // Disable these warnings for VS2013.
> //
> 
> //
> // This warning is for potentially uninitialized local variable, and it may 
> cause false 
> // positive issues in VS2013 and VS2015 build
> //
> #pragma warning ( disable : 4701 )
>   
> //
> // This warning is for potentially uninitialized local pointer variable, and 
> it may cause 
> // false positive issues in VS2013 and VS2015 build
> //
> #pragma warning ( disable : 4703 )
>   
> #endif
> 
> #endif

I think starting with gcc-4.6, gcc supports the "diagnostics" pragma,
which can be used to suppress warnings.

Unfortunately, there's no pragma to suppress *only* the incorrect
warnings :) So if we set the pragma, we could lose even those warnings
that point out real bugs.

Thanks
Laszlo

> 
> 
> Thanks,
> Star
> -----Original Message-----
> From: Zeng, Star 
> Sent: Wednesday, September 13, 2017 2:34 PM
> To: Laszlo Ersek <[email protected]>; edk2-devel-01 <[email protected]>
> Cc: Ard Biesheuvel <[email protected]>; Dong, Eric 
> <[email protected]>; Paulo Alcantara <[email protected]>; Ni, Ruiyu 
> <[email protected]>; Zeng, Star <[email protected]>
> Subject: RE: [PATCH 2/2] MdeModulePkg/UdfDxe: suppress incorrect compiler 
> warning in ReadFile()
> 
> Reviewed-by: Star Zeng <[email protected]>
> 
> -----Original Message-----
> From: Laszlo Ersek [mailto:[email protected]]
> Sent: Wednesday, September 13, 2017 6:26 AM
> To: edk2-devel-01 <[email protected]>
> Cc: Ard Biesheuvel <[email protected]>; Dong, Eric 
> <[email protected]>; Paulo Alcantara <[email protected]>; Ni, Ruiyu 
> <[email protected]>; Zeng, Star <[email protected]>
> Subject: [PATCH 2/2] MdeModulePkg/UdfDxe: suppress incorrect compiler warning 
> in ReadFile()
> 
> When building the driver for DEBUG/RELEASE, GCC48/GCC49 warn about
> ReadFile() possibly using "BytesLeft" without initializing it first.
> 
> This is not the case. The reads of "BytesLeft" are only reachable if 
> (ReadFileInfo->Flags == READ_FILE_SEEK_AND_READ). But, in that case, we also 
> set "BytesLeft" to "ReadFileInfo->FileDataSize", near the top of the function.
> 
> Assign "BytesLeft" zero at the top, and add a comment that conforms to the 
> pending Coding Style Spec feature request at 
> <https://bugzilla.tianocore.org/show_bug.cgi?id=607>.
> 
> This issue was reported by Ard's and Gerd's CI systems independently.
> 
> Cc: Ard Biesheuvel <[email protected]>
> Cc: Eric Dong <[email protected]>
> Cc: Paulo Alcantara <[email protected]>
> Cc: Ruiyu Ni <[email protected]>
> Cc: Star Zeng <[email protected]>
> Reported-by: Ard Biesheuvel <[email protected]>
> Reported-by: Gerd Hoffmann <[email protected]>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <[email protected]>
> ---
>  MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c 
> b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
> index 096fbb4452cb..392494b2eb3f 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
> @@ -893,6 +893,11 @@ ReadFile (
>    LogicalBlockSize  = LV_BLOCK_SIZE (Volume, UDF_DEFAULT_LV_NUM);
>    DoFreeAed         = FALSE;
>  
> +  //
> +  // set BytesLeft to suppress incorrect compiler/analyzer warnings  // 
> + BytesLeft = 0;
> +
>    switch (ReadFileInfo->Flags) {
>    case READ_FILE_GET_FILESIZE:
>    case READ_FILE_ALLOCATE_AND_READ:
> --
> 2.14.1.3.gb7cf6e02401b
> 

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

Reply via email to