From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 1C27521E87986 for ; Wed, 13 Sep 2017 11:46:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C20974A6E4; Wed, 13 Sep 2017 18:49:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C20974A6E4 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-116.rdu2.redhat.com [10.10.120.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 067FB4D9E6; Wed, 13 Sep 2017 18:49:28 +0000 (UTC) To: "Zeng, Star" , edk2-devel-01 Cc: Ard Biesheuvel , "Dong, Eric" , Paulo Alcantara , "Ni, Ruiyu" , "Gao, Liming" References: <20170912222612.14451-1-lersek@redhat.com> <20170912222612.14451-3-lersek@redhat.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B94098B@shsmsx102.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9409E7@shsmsx102.ccr.corp.intel.com> From: Laszlo Ersek Message-ID: <23e789a8-59df-d67d-fa16-fc70aafb95d7@redhat.com> Date: Wed, 13 Sep 2017 20:49:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9409E7@shsmsx102.ccr.corp.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 13 Sep 2017 18:49:30 +0000 (UTC) Subject: Re: [PATCH 2/2] MdeModulePkg/UdfDxe: suppress incorrect compiler warning in ReadFile() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Sep 2017 18:46:33 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 ; edk2-devel-01 > Cc: Ard Biesheuvel ; Dong, Eric ; Paulo Alcantara ; Ni, Ruiyu ; Zeng, Star > Subject: RE: [PATCH 2/2] MdeModulePkg/UdfDxe: suppress incorrect compiler warning in ReadFile() > > Reviewed-by: Star Zeng > > -----Original Message----- > From: Laszlo Ersek [mailto:lersek@redhat.com] > Sent: Wednesday, September 13, 2017 6:26 AM > To: edk2-devel-01 > Cc: Ard Biesheuvel ; Dong, Eric ; Paulo Alcantara ; Ni, Ruiyu ; Zeng, Star > 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 . > > This issue was reported by Ard's and Gerd's CI systems independently. > > Cc: Ard Biesheuvel > Cc: Eric Dong > Cc: Paulo Alcantara > Cc: Ruiyu Ni > Cc: Star Zeng > Reported-by: Ard Biesheuvel > Reported-by: Gerd Hoffmann > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Laszlo Ersek > --- > 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 >