From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in6.apple.com (mail-out6.apple.com [17.151.62.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 A27B321A16ED8 for ; Wed, 17 May 2017 20:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1495076809; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fvU9wN3Qc4WXioaumYyWBMRYvwIK1junNTm9WwJggHE=; b=vtXbLSN+Qr/VKehxF75sVZiOXpZFuni+4ZtJMtwlFf2sjpWz29yAaI0zzCrUqeJg yFU4lbF3cXTfgEP8rp7fwBUwwexyU7g9lTDdHoZeJYhewN9mPV6AtS/nOUI47gKZ XuMIJBdGKN8S3TgCfp0gB4c+UqSCYaQcsYrk/bPUrYVeW+8xkGvorgJFxXkXzjpF BPMDjFtspvJX897gMwyuAIaY0OU2u3TIcWwOfDSAGI1AZCrfR6KLVwDI0CxQlCSU 0tGik3VqMoRfSPmdvSI6eBDnDiJVZXAtwbaFlGhnu/bWKcoghlfQCXh1N/AucRg9 WFDitE+vwM3401a8PdWp+w==; Received: from relay6.apple.com (relay6.apple.com [17.128.113.90]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in6.apple.com (Apple Secure Mail Relay) with SMTP id 82.62.26227.9CF0D195; Wed, 17 May 2017 20:06:49 -0700 (PDT) X-AuditID: 11973e15-5b52c9a000006673-b1-591d0fc90b85 Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by relay6.apple.com (Apple SCV relay) with SMTP id 07.3A.09762.8CF0D195; Wed, 17 May 2017 20:06:49 -0700 (PDT) MIME-version: 1.0 Received: from [17.114.155.115] by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0OQ4002H5ONCXV80@nwk-mmpp-sz13.apple.com>; Wed, 17 May 2017 20:06:48 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Wed, 17 May 2017 20:06:48 -0700 Cc: "Gao, Liming" , "edk2-devel@lists.01.org" Message-id: References: <1494903391-716-1-git-send-email-s.temerkhanov@gmail.com> <1494903391-716-2-git-send-email-s.temerkhanov@gmail.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14D72E8BC@shsmsx102.ccr.corp.intel.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14D730154@shsmsx102.ccr.corp.intel.com> To: Sergei Temerkhanov X-Mailer: Apple Mail (2.3273) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsUi2FAYpXuSXzbS4PpvYYs9h44yW6y4t4Hd YumsfewOzB47Z91l91i85yWTR/fsfywBzFFcNimpOZllqUX6dglcGY03JjIXrFKqaN+7m6mB caJMFyMnh4SAicSLu49Yuhi5OIQEVjNJrH75mh0m0TB9DxtE4hCjxJ83SxlBErwCghI/Jt8D 6uDgYBaQlzh4XhYkzCygJfH9USvUoG+MEnMu3WUDSQgLiEu8O7OJGcIOlji3+CoriM0moCyx Yv4HsGWcQPFHlx6ygNgsAqoSszfNZYEYGi9x49tWJoi9NhJrL7xgh1iwmFni3fEOVpAjRAQM JI6vcYA4Wlbi1uxLzCA1EgJb2CQuv1zGNIFReBaSu2ch3D0Lyd0LGJlXMQrlJmbm6Gbmmekl FhTkpOol5+duYgSF+3Q70R2MZ1ZZHWIU4GBU4uHdECQTKcSaWFZcmXuIUZqDRUmcN3QzUEgg PbEkN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ere: 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: Thu, 18 May 2017 03:06:49 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Sergei, We are hitting this too. Our temporary work around was to suppress the warning for the libraries via our platforms DSC file so we did not need to override things in edk2. You can override the library build options if you add them to the [Components] section. MdePkg/Library/UefiLib/UefiLib.inf { XCODE:*_*_*_CC_FLAGS = -Wno-varargs } Thanks, Andrew Fish > On May 17, 2017, at 5:26 PM, Sergei Temerkhanov wrote: > > On Wed, May 17, 2017 at 6:30 PM, Gao, Liming wrote: >> Sergey: >> Now, VS and GCC don't report such issue. How do you find them? > > Clang build for ARM64 revealed it. > >> And, this change modifies the function API, does it impact the consumer code? > > No changes to the consumer code are needed - integer promotions are > handled by the compilers. In fact, even the ABI remains the same b/c > full words are passed as function parameters. > > Regards, > Sergey > >> >> Thanks >> Liming >>> -----Original Message----- >>> From: Sergei Temerkhanov [mailto:s.temerkhanov@gmail.com] >>> Sent: Tuesday, May 16, 2017 8:11 PM >>> To: Gao, Liming >>> Cc: edk2-devel@lists.01.org >>> Subject: Re: [edk2] [PATCH] MdePkg: Fix undefined behavior on variadic parameters >>> >>> On Tue, May 16, 2017 at 8:10 AM, Gao, Liming wrote: >>>> Sergey: >>>> Could you give more detail on the undefined behavior on variadic parameters? >>>> >>>> I see https://bugzilla.tianocore.org/show_bug.cgi?id=410 describe this issues found in the latest CLANG tool chain. Do you find >>> other tool chain reports it? >>> >>> Yes, this is exactly the bug this patch fixes. >>> >>> As per the C99 standard: >>> "The parameter parmN is the identifier of the rightmost parameter in >>> the variable parameter list in the function definition (the one just >>> before the , ...). If the parameter parmN is declared with the >>> register storage class, with a function or array type, or with a type >>> that is not compatible with the type that results after application of >>> the default argument promotions, the behavior is undefined." >>> >>> That's exactly the case here since BOOLEAN is a typedef for unsigned >>> char. It undergoes a promotion to an unsigned int which is not a >>> compatible type for unsigned char. Correct me if I'm wrong. >>> >>> Regards, >>> Sergey >>> >>>> >>>> Thanks >>>> Liming >>>>> -----Original Message----- >>>>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Sergey Temerkhanov >>>>> Sent: Tuesday, May 16, 2017 10:57 AM >>>>> To: edk2-devel@lists.01.org >>>>> Subject: [edk2] [PATCH] MdePkg: Fix undefined behavior on variadic parameters >>>>> >>>>> Fix undefined behavior by avoiding parameter type promotion >>>>> >>>>> Signed-off-by: Sergey Temerkhanov >>>>> --- >>>>> MdePkg/Include/Library/UefiLib.h | 2 +- >>>>> MdePkg/Library/UefiLib/UefiLib.c | 2 +- >>>>> 2 files changed, 2 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h >>>>> index 0b14792..4e4697c 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 UINTN Iso639Language, >>>>> ... >>>>> ); >>>>> >>>>> diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c >>>>> index a7eee01..74528ec 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 UINTN Iso639Language, >>>>> ... >>>>> ) >>>>> { >>>>> -- >>>>> 2.7.4 >>>>> >>>>> _______________________________________________ >>>>> edk2-devel mailing list >>>>> edk2-devel@lists.01.org >>>>> https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel