From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 191D520356262 for ; Sun, 10 Dec 2017 05:47:58 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2017 05:52:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,388,1508828400"; d="scan'208";a="185692810" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 10 Dec 2017 05:52:34 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 10 Dec 2017 05:52:34 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Sun, 10 Dec 2017 21:52:32 +0800 From: "Gao, Liming" To: Zenith432 , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH] MdePkg: resolve bug 741 Thread-Index: AQHTcSYTNYo9TkC0r0eYQQSZJz+um6M8eFZw Date: Sun, 10 Dec 2017 13:52:32 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E18E292@SHSMSX104.ccr.corp.intel.com> References: <541697813.1899563.1512848632833.ref@mail.yahoo.com> <541697813.1899563.1512848632833@mail.yahoo.com> In-Reply-To: <541697813.1899563.1512848632833@mail.yahoo.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg: resolve bug 741 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: Sun, 10 Dec 2017 13:47:59 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable For 4, 'unsigned char' goes default argument promotion to int. This is CLAN= G compiler behavior. Does GCC and VS compiler follow this rule? Disable varargs warning is the temp solution. For long term, we expect to f= igure out the compatible solution. If all supported compilers follow this r= ule, I think this is a compatible change.=20 > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ze= nith432 > Sent: Sunday, December 10, 2017 3:44 AM > To: edk2-devel@lists.01.org > Subject: [edk2] [PATCH] MdePkg: resolve bug 741 >=20 > This is a proposal to resolve bug 741: UefiLib.c compilation failure with= clang > error: passing an object that undergoes default argument promotion to 'va= _start' has undefined behavior [-Werror,-Wvarargs]" >=20 > Rationale: > 1. Default argument promotion causes the sizeof a function's argument to = be different than the corresponding > parameter's sizeof. This may break a permissible implemenation of stdarg= .h, which is why it is considered > undefined behavior in C. The condition should be repaired rather than si= lenced with -Wno-varargs. > 2. The warning is due to the last non-variadic parameter of GetBestLangua= ge having type BOOLEAN. > 3. BOOLEAN is typedef'd to 'unsigned char' in all ProcessorBind.h. > 4. 'unsigned char' goes default argument promotion to int. > 5. All ProcessorBind.h typedef the type INT32 to either 'int' or some 32-= bit equivalent. > 6. As a result it is safe to replace the type of the parameter from BOOLE= AN to INT32 in all > current supported architectures. > 7. The change is consistent with the BOOLEAN argument being converted to = INT32 at the caller site. The > function GetBestLanguage currently converts the argument from INT32 back = to BOOLEAN, however > the function's logic is not disturbed by treating the argument as an INT3= 2. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Zenith432 > --- > MdePkg/Include/Library/UefiLib.h | 2 +- > MdePkg/Library/UefiLib/UefiLib.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/Ue= fiLib.h > index 0b14792a..5d98eb26 100644 > --- a/MdePkg/Include/Library/UefiLib.h > +++ b/MdePkg/Include/Library/UefiLib.h > @@ -818,7 +818,7 @@ CHAR8 * > EFIAPI > GetBestLanguage ( > IN CONST CHAR8 *SupportedLanguages, > - IN BOOLEAN Iso639Language, > + IN INT32 Iso639Language, > ... > ); >=20 > diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/Ue= fiLib.c > index a7eee012..57236511 100644 > --- a/MdePkg/Library/UefiLib/UefiLib.c > +++ b/MdePkg/Library/UefiLib/UefiLib.c > @@ -1514,7 +1514,7 @@ CHAR8 * > EFIAPI > GetBestLanguage ( > IN CONST CHAR8 *SupportedLanguages, > - IN BOOLEAN Iso639Language, > + IN INT32 Iso639Language, > ... > ) > { > -- > 2.14.3 (Apple Git-98) > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel