From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 AA19C21E87964 for ; Tue, 12 Sep 2017 23:40:57 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2017 23:43:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,386,1500966000"; d="scan'208";a="151254314" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 12 Sep 2017 23:43:54 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Sep 2017 23:43:53 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Sep 2017 23:43:53 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.39]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.117]) with mapi id 14.03.0319.002; Wed, 13 Sep 2017 14:43:51 +0800 From: "Zeng, Star" To: Laszlo Ersek , edk2-devel-01 CC: Ard Biesheuvel , "Dong, Eric" , Paulo Alcantara , "Ni, Ruiyu" , "Gao, Liming" , "Zeng, Star" Thread-Topic: [PATCH 2/2] MdeModulePkg/UdfDxe: suppress incorrect compiler warning in ReadFile() Thread-Index: AQHTLBYspwdYPe7xxk2VyqRg2zXQbKKyXCZQgAAAteA= Date: Wed, 13 Sep 2017 06:43:51 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9409E7@shsmsx102.ccr.corp.intel.com> References: <20170912222612.14451-1-lersek@redhat.com> <20170912222612.14451-3-lersek@redhat.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B94098B@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B94098B@shsmsx102.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 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 06:40:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Beyond the Rb (I do not want to block this patch series), I am curious abou= t 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 speci= fic version of GCC for this kind of false alarm? ProcessorBind.h: #if defined(_MSC_EXTENSIONS) ... #if _MSC_VER =3D=3D 1800 || _MSC_VER =3D=3D 1900 // // Disable these warnings for VS2013. // // // This warning is for potentially uninitialized local variable, and it may= cause false=20 // positive issues in VS2013 and VS2015 build // #pragma warning ( disable : 4701 ) =20 // // This warning is for potentially uninitialized local pointer variable, an= d it may cause=20 // false positive issues in VS2013 and VS2015 build // #pragma warning ( disable : 4703 ) =20 #endif #endif Thanks, Star -----Original Message----- From: Zeng, Star=20 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 w= arning 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 warni= ng 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 (ReadF= ileInfo->Flags =3D=3D READ_FILE_SEEK_AND_READ). But, in that case, we also = set "BytesLeft" to "ReadFileInfo->FileDataSize", near the top of the functi= on. 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/Md= eModulePkg/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 =3D LV_BLOCK_SIZE (Volume, UDF_DEFAULT_LV_NUM); DoFreeAed =3D FALSE; =20 + // + // set BytesLeft to suppress incorrect compiler/analyzer warnings //=20 + BytesLeft =3D 0; + switch (ReadFileInfo->Flags) { case READ_FILE_GET_FILESIZE: case READ_FILE_ALLOCATE_AND_READ: -- 2.14.1.3.gb7cf6e02401b