From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-x242.google.com (mail-vk0-x242.google.com [IPv6:2607:f8b0:400c:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 604EE21A16EC1 for ; Thu, 18 May 2017 20:01:59 -0700 (PDT) Received: by mail-vk0-x242.google.com with SMTP id h16so724903vkd.0 for ; Thu, 18 May 2017 20:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lqxsFy/K0/I0z4La3K971gP5fiLj5DwHJvDbJ5aKJCQ=; b=ezbVxQPvOEWBfAcW9333EmkRd2fW1lp4BE2I4KD/bXEyAobHDvt5w7U5qRuMEmSjwV BrKSof6Ze56wmGVknI3AlbMGXCEG2qLGcymwid2I9TSzv0ZHiYIPTdb1w3E7FWam4zij Op3c05moQqKfkKOQnIYUOKfZa9CiJ+FDqbQQBHNS2Y1r6DGFioWIR5o+2Jr/np++ebrp IPUIpsuE4Dsk+zcRmdMe1jVvHXDn+fni1AYb/UVDgJ2y+js5Sw/6QoPZMuO5Z+01aj1a PaOt2EcPkmb0uFJcc++2h+4ld0HlUpYW7sbUxg7jILMgmakQxGLqbRShr+2z93V+zLzZ KsVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lqxsFy/K0/I0z4La3K971gP5fiLj5DwHJvDbJ5aKJCQ=; b=McUrmU2DalnLri8r9ANKttNVm/ly9DbUz70i5Na+lq1KmHlcGr8UW+VvNhmrTrZ58b cBDDnqj77PwT0dxrgh+K1I9SnOcsoHDdq7FoE4R/bHzGYScPOVUd6GCF8x5iF7rprtOb Yh2UoJRPVE5uBc40h+RxAfoFEUDXIUBtZmaNCcBbMkmKwIqCyICT9pPINfwOj7hH7fuk LilBzNyhOUosynjQBBddfk3UglmQ4GQ68ULNIR1Nz8HZerjo9k0CcDSoToOOdeTXfYKS wobEN9r2tZ22ohHVvpm44c/Mhsi9yMmSLmTHEAlPGbt0X3HA1Y7i7C5SQ5hEwLgvS+pU ySkg== X-Gm-Message-State: AODbwcDCA2GKoSVnJxZRp8wBhWOnkP3OhpGbBKocm3qko2TOFWY92sLm 4r6bBgyrOSZoULXHX59yb0ktCI/pqQ== X-Received: by 10.31.152.209 with SMTP id a200mr598177vke.19.1495162918493; Thu, 18 May 2017 20:01:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.35.78 with HTTP; Thu, 18 May 2017 20:01:58 -0700 (PDT) In-Reply-To: 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> From: Sergei Temerkhanov Date: Fri, 19 May 2017 06:01:58 +0300 Message-ID: To: Andrew Fish Cc: "Gao, Liming" , "edk2-devel@lists.01.org" Subject: Re: [PATCH] MdePkg: Fix undefined behavior on variadic parameters 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: Fri, 19 May 2017 03:01:59 -0000 Content-Type: text/plain; charset="UTF-8" On Thu, May 18, 2017 at 6:06 AM, Andrew Fish wrote: > 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 That would be GCC: *_CLANG38_*_CC_FLAGS at least > } > > 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 >