<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
This looks to me not quite intuitional.</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
 !(!TryBestLanguage && Language == NULL) seems more straightforward and exactly what we would like to catch.</div>
<div id="ms-outlook-mobile-signature" dir="auto" style="text-align: left;">
<div><br>
</div>
<div dir="auto" style="text-align: left;">Abner </div>
<div dir="auto" style="text-align: left;"><br>
</div>
Get <a href="https://aka.ms/ghei36">Outlook for Android</a></div>
<div id="id-eb242f6b-27c7-4609-9248-32c8ce4dfbb8" class="ms-outlook-mobile-reference-message">
<div style="font-family: sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg"><strong>From:</strong> devel@edk2.groups.io <devel@edk2.groups.io> on behalf of gaoliming <gaoliming@byosoft.com.cn><br>
<strong>Sent:</strong> Thursday, February 4, 2021, 3:13 PM<br>
<strong>To:</strong> devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist); dandan.bi@intel.com<br>
<strong>Cc:</strong> 'Dong, Eric'; Wang, Nickle (HPS SW)<br>
<strong>Subject:</strong> 回复: [edk2-devel] [PATCH v3] MdeModulePkg/Library: Add HiiGetStringEx to UefiHiiLib for EDK2 Redfish<br>
</div>
<br>
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style><font size="2"><span style="font-size:11pt;">
<div class="PlainText">If TryBestLanguage is FALE and Language is NULL, then ASSERT().<br>
<br>
So, ASSERT statement should be ASSERT (TryBestLanguage || (Language !=<br>
NULL)); <br>
<br>
Is this clear?<br>
<br>
Thanks<br>
Liming<br>
> -----邮件原件-----<br>
> 发件人: bounce+27952+71110+4905953+8761045@groups.io<br>
> <bounce+27952+71110+4905953+8761045@groups.io> 代表 Abner Chang<br>
> 发送时间: 2021年2月3日 23:21<br>
> 收件人: devel@edk2.groups.io; dandan.bi@intel.com<br>
> 抄送: Dong, Eric <eric.dong@intel.com>; Wang, Nickle (HPS SW)<br>
> <nickle.wang@hpe.com><br>
> 主题: Re: [edk2-devel] [PATCH v3] MdeModulePkg/Library: Add<br>
> HiiGetStringEx to UefiHiiLib for EDK2 Redfish<br>
> <br>
> Yes Dandan, yours follow coding standard. I will handle that.<br>
> Also, I will help to push the patch to upstream with your review tag.<br>
> <br>
> Thanks<br>
> Abner<br>
> <br>
> > -----Original Message-----<br>
> > From: devel@edk2.groups.io [<a href="mailto:devel@edk2.groups.io">mailto:devel@edk2.groups.io</a>] On Behalf Of<br>
> > Dandan Bi<br>
> > Sent: Wednesday, February 3, 2021 7:34 PM<br>
> > To: Chang, Abner (HPS SW/FW Technologist) <abner.chang@hpe.com>;<br>
> > devel@edk2.groups.io<br>
> > Cc: Dong, Eric <eric.dong@intel.com>; Wang, Nickle (HPS SW)<br>
> > <nickle.wang@hpe.com><br>
> > Subject: Re: [edk2-devel] [PATCH v3] MdeModulePkg/Library: Add<br>
> > HiiGetStringEx to UefiHiiLib for EDK2 Redfish<br>
> ><br>
> > One minor comment inline below.<br>
> > Reviewed-by: Dandan Bi <dandan.bi@intel.com> with this is handled.<br>
> ><br>
> > Thanks,<br>
> > Dandan<br>
> > > -----Original Message-----<br>
> > > From: Abner Chang <abner.chang@hpe.com><br>
> > > Sent: Monday, February 1, 2021 11:06 AM<br>
> > > To: devel@edk2.groups.io<br>
> > > Cc: Bi, Dandan <dandan.bi@intel.com>; Dong, Eric<br>
> > > <eric.dong@intel.com>; Nickle Wang <nickle.wang@hpe.com><br>
> > > Subject: [PATCH v3] MdeModulePkg/Library: Add HiiGetStringEx to<br>
> > > UefiHiiLib for EDK2 Redfish<br>
> > ><br>
> > > Add HiiGetStringEx and leveraged by HiiGetString function to support<br>
> > > getting string with the best language in optionally. This avoids the<br>
> > > string in x-uefi language is misled to the language defined by<br>
> > > "PlatformLang" or the "Supported Languages". This change is introduced<br>
> > > to support x-uefi keyword language for configuring BIOS setting.<br>
> > ><br>
> > > Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com><br>
> > > Signed-off-by: Siyuan Fu <siyuan.fu@intel.com><br>
> > > Signed-off-by: Fan Wang <fan.wang@intel.com><br>
> > > Signed-off-by: Abner Chang <abner.chang@hpe.com><br>
> > > Cc: Dandan Bi <dandan.bi@intel.com><br>
> > > Cc: Eric Dong <eric.dong@intel.com><br>
> > > Cc: Nickle Wang <nickle.wang@hpe.com><br>
> > > ---<br>
> > >  MdeModulePkg/Include/Library/HiiLib.h       | 60 ++++++++++---<br>
> > >  MdeModulePkg/Library/UefiHiiLib/HiiString.c | 98<br>
> > > +++++++++++++++------<br>
> > >  2 files changed, 119 insertions(+), 39 deletions(-)<br>
> > ><br>
> > > diff --git a/MdeModulePkg/Include/Library/HiiLib.h<br>
> > > b/MdeModulePkg/Include/Library/HiiLib.h<br>
> > > index c475cb74a1..cd9027fefd 100644<br>
> > > --- a/MdeModulePkg/Include/Library/HiiLib.h<br>
> > > +++ b/MdeModulePkg/Include/Library/HiiLib.h<br>
> > > @@ -1,7 +1,8 @@<br>
> > >  /** @file<br>
> > >    Public include file for the HII Library<br>
> > ><br>
> > > -Copyright (c) 2007 - 2018, Intel Corporation. All rights<br>
> > > reserved.<BR><br>
> > > +Copyright (c) 2007 - 2021, Intel Corporation. All rights<br>
> > > +reserved.<BR><br>
> > > +(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR><br>
> > >  SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> > ><br>
> > >  **/<br>
> > > @@ -123,16 +124,8 @@ HiiSetString (<br>
> > >  ;<br>
> > ><br>
> > >  /**<br>
> > > -  Retrieves a string from a string package in a specific language.<br>
> > > If the language<br>
> > > -  is not specified, then a string from a string package in the<br>
> > > current platform<br>
> > > -  language is retrieved.  If the string cannot be retrieved using the<br>
> > > specified<br>
> > > -  language or the current platform language, then the string is<br>
> > > retrieved from<br>
> > > -  the string package in the first language the string package<br>
> > > supports.  The<br>
> > > -  returned string is allocated using AllocatePool().  The caller is<br>
> > > responsible<br>
> > > -  for freeing the allocated buffer using FreePool().<br>
> > > -<br>
> > > -  If HiiHandle is NULL, then ASSERT().<br>
> > > -  If StringId is 0, then ASSERT().<br>
> > > +  Retrieves a string from a string package in a specific language<br>
> > > + specified in Language  or in the best lanaguage. See HiiGetStringEx<br>
> > > + () for<br>
> > > the details.<br>
> > ><br>
> > >    @param[in]  HiiHandle  A handle that was previously registered in<br>
> > > the HII Database.<br>
> > >    @param[in]  StringId   The identifier of the string to retrieved<br>
from<br>
> the<br>
> > > string<br>
> > > @@ -152,8 +145,49 @@ HiiGetString (<br>
> > >    IN EFI_HII_HANDLE  HiiHandle,<br>
> > >    IN EFI_STRING_ID   StringId,<br>
> > >    IN CONST CHAR8     *Language  OPTIONAL<br>
> > > -  )<br>
> > > -;<br>
> > > +  );<br>
> > > +<br>
> > > +/**<br>
> > > +  Retrieves a string from a string package in a specific language or<br>
> > > +in the best<br>
> > > +  language at discretion of this function according to the priority<br>
of<br>
> > languages.<br>
> > > +  TryBestLanguage is used to get the string in the best language or<br>
> > > +in the language<br>
> > > +  specified in Language parameter. The behavior is,<br>
> > > +  If TryBestLanguage is TRUE, this function looks for the best<br>
> > > +language for<br>
> > > the string.<br>
> > > +   - If the string can not be retrieved using the specified language<br>
> > > + or the<br>
> > > current<br>
> > > +     platform language, then the string is retrieved from the string<br>
> > > + package in<br>
> > > the<br>
> > > +     first language the string package supports.<br>
> > > +  If TryBestLanguage is FALSE, Language must be specified for<br>
> > > + retrieving the<br>
> > > string.<br>
> > > +<br>
> > > +  The returned string is allocated using AllocatePool().  The caller<br>
> > > + is responsible  for freeing the allocated buffer using FreePool().<br>
> > > +<br>
> > > +  If HiiHandle is NULL, then ASSERT().<br>
> > > +  If StringId is 0, then ASSET.<br>
> > > +  If TryBestLanguage is FALE and Language is NULL, then ASSERT().<br>
> > > +<br>
> > > +  @param[in]  HiiHandle         A handle that was previously<br>
> registered in the<br>
> > > HII Database.<br>
> > > +  @param[in]  StringId          The identifier of the string to<br>
> retrieved from<br>
> > the<br>
> > > string<br>
> > > +                                package associated with<br>
> HiiHandle.<br>
> > > +  @param[in]  Language          The language of the string to<br>
> retrieve.  If this<br>
> > > parameter<br>
> > > +                                is NULL, then the current<br>
> platform language is used.  The<br>
> > > +                                format of Language must follow<br>
> the<br>
> > > + language format<br>
> > > assumed<br>
> > > +                                the HII Database.<br>
> > > +  @param[in]  TryBestLanguage   If TRUE, try to get the best<br>
> matching<br>
> > > language from all<br>
> > > +                                supported languages.If FALSE,<br>
> the<br>
> > > + Language must be<br>
> > > assigned<br>
> > > +                                for the StringID.<br>
> > > +<br>
> > > +  @retval NULL   The string specified by StringId is not present in<br>
the<br>
> string<br>
> > > package.<br>
> > > +  @retval Other  The string was returned.<br>
> > > +<br>
> > > +**/<br>
> > > +EFI_STRING<br>
> > > +EFIAPI<br>
> > > +HiiGetStringEx (<br>
> > > +  IN EFI_HII_HANDLE  HiiHandle,<br>
> > > +  IN EFI_STRING_ID   StringId,<br>
> > > +  IN CONST CHAR8     *Language  OPTIONAL,<br>
> > > +  IN BOOLEAN         TryBestLanguage<br>
> > > +  );<br>
> > ><br>
> > >  /**<br>
> > >    Retrieves a string from a string package named by GUID, in the<br>
> > > specified language.<br>
> > > diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiString.c<br>
> > > b/MdeModulePkg/Library/UefiHiiLib/HiiString.c<br>
> > > index 95229f8a8c..a9a11aef98 100644<br>
> > > --- a/MdeModulePkg/Library/UefiHiiLib/HiiString.c<br>
> > > +++ b/MdeModulePkg/Library/UefiHiiLib/HiiString.c<br>
> > > @@ -1,7 +1,8 @@<br>
> > >  /** @file<br>
> > >    HII Library implementation that uses DXE protocols and services.<br>
> > ><br>
> > > -  Copyright (c) 2006 - 2018, Intel Corporation. All rights<br>
> > > reserved.<BR><br>
> > > +  Copyright (c) 2006 - 2021, Intel Corporation. All rights<br>
> > > + reserved.<BR><br>
> > > + (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR><br>
> > >    SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> > ><br>
> > >  **/<br>
> > > @@ -190,16 +191,8 @@ HiiGetPackageString (  }<br>
> > ><br>
> > >  /**<br>
> > > -  Retrieves a string from a string package in a specific language.<br>
> > > If the language<br>
> > > -  is not specified, then a string from a string package in the<br>
> > > current platform<br>
> > > -  language is retrieved.  If the string can not be retrieved using<br>
> > > the specified<br>
> > > -  language or the current platform language, then the string is<br>
> > > retrieved from<br>
> > > -  the string package in the first language the string package<br>
> > > supports.  The<br>
> > > -  returned string is allocated using AllocatePool().  The caller is<br>
> > > responsible<br>
> > > -  for freeing the allocated buffer using FreePool().<br>
> > > -<br>
> > > -  If HiiHandle is NULL, then ASSERT().<br>
> > > -  If StringId is 0, then ASSET.<br>
> > > +  Retrieves a string from a string package in a specific language<br>
> > > + specified in Language  or in the best lanaguage. See HiiGetStringEx<br>
> > > + () for<br>
> > > the details.<br>
> > ><br>
> > >    @param[in]  HiiHandle  A handle that was previously registered in<br>
> > > the HII Database.<br>
> > >    @param[in]  StringId   The identifier of the string to retrieved<br>
from<br>
> the<br>
> > > string<br>
> > > @@ -220,6 +213,51 @@ HiiGetString (<br>
> > >    IN EFI_STRING_ID   StringId,<br>
> > >    IN CONST CHAR8     *Language  OPTIONAL<br>
> > >    )<br>
> > > +{<br>
> > > +  return HiiGetStringEx (HiiHandle, StringId, Language, TRUE); }<br>
> > > +<br>
> > > +/**<br>
> > > +  Retrieves a string from a string package in a specific language or<br>
> > > +in the best<br>
> > > +  language at discretion of this function according to the priority<br>
of<br>
> > languages.<br>
> > > +  TryBestLanguage is used to get the string in the best language or<br>
> > > +in the language<br>
> > > +  specified in Language parameter. The behavior is,<br>
> > > +  If TryBestLanguage is TRUE, this function looks for the best<br>
> > > +language for<br>
> > > the string.<br>
> > > +   - If the string can not be retrieved using the specified language<br>
> > > + or the<br>
> > > current<br>
> > > +     platform language, then the string is retrieved from the string<br>
> > > + package in<br>
> > > the<br>
> > > +     first language the string package supports.<br>
> > > +  If TryBestLanguage is FALSE, Language must be specified for<br>
> > > + retrieving the<br>
> > > string.<br>
> > > +<br>
> > > +  The returned string is allocated using AllocatePool().  The caller<br>
> > > + is responsible  for freeing the allocated buffer using FreePool().<br>
> > > +<br>
> > > +  If HiiHandle is NULL, then ASSERT().<br>
> > > +  If StringId is 0, then ASSET.<br>
> > > +  If TryBestLanguage is FALE and Language is NULL, then ASSERT().<br>
> > > +<br>
> > > +  @param[in]  HiiHandle         A handle that was previously<br>
> registered in the<br>
> > > HII Database.<br>
> > > +  @param[in]  StringId          The identifier of the string to<br>
> retrieved from<br>
> > the<br>
> > > string<br>
> > > +                                package associated with<br>
> HiiHandle.<br>
> > > +  @param[in]  Language          The language of the string to<br>
> retrieve.  If this<br>
> > > parameter<br>
> > > +                                is NULL, then the current<br>
> platform language is used.  The<br>
> > > +                                format of Language must follow<br>
> the<br>
> > > + language format<br>
> > > assumed<br>
> > > +                                the HII Database.<br>
> > > +  @param[in]  TryBestLanguage   If TRUE, try to get the best<br>
> matching<br>
> > > language from all<br>
> > > +                                supported languages.If FALSE,<br>
> the<br>
> > > + Language must be<br>
> > > assigned<br>
> > > +                                for the StringID.<br>
> > > +<br>
> > > +  @retval NULL   The string specified by StringId is not present in<br>
the<br>
> string<br>
> > > package.<br>
> > > +  @retval Other  The string was returned.<br>
> > > +<br>
> > > +**/<br>
> > > +EFI_STRING<br>
> > > +EFIAPI<br>
> > > +HiiGetStringEx (<br>
> > > +  IN EFI_HII_HANDLE  HiiHandle,<br>
> > > +  IN EFI_STRING_ID   StringId,<br>
> > > +  IN CONST CHAR8     *Language  OPTIONAL,<br>
> > > +  IN BOOLEAN         TryBestLanguage<br>
> > > +  )<br>
> > >  {<br>
> > >    EFI_STATUS  Status;<br>
> > >    UINTN       StringSize;<br>
> > > @@ -231,7 +269,10 @@ HiiGetString (<br>
> > ><br>
> > >    ASSERT (HiiHandle != NULL);<br>
> > >    ASSERT (StringId != 0);<br>
> > > -<br>
> > > +  //<br>
> > > +  // Language must be specified if TryBestLanguage = FALSE.<br>
> > > +  //<br>
> > > +  ASSERT (!(TryBestLanguage == FALSE && Language == NULL));<br>
> > One minor here, in order to following the coding style, this seems<br>
should be<br>
> > ASSERT (!(!TryBestLanguage && Language == NULL)); Please help double<br>
> > check.<br>
> ><br>
> > >    //<br>
> > >    // Initialize all allocated buffers to NULL<br>
> > >    //<br>
> > > @@ -261,21 +302,26 @@ HiiGetString (<br>
> > >      Language = "";<br>
> > >    }<br>
> > ><br>
> > > -  //<br>
> > > -  // Get the best matching language from SupportedLanguages<br>
> > > -  //<br>
> > > -  BestLanguage = GetBestLanguage (<br>
> > > -                   SupportedLanguages,<br>
> > > -                   FALSE,<br>
> // RFC 4646 mode<br>
> > > -                   Language,<br>
> // Highest priority<br>
> > > -                   PlatformLanguage != NULL ? PlatformLanguage :<br>
> "",  // Next<br>
> > > highest priority<br>
> > > -                   SupportedLanguages,<br>
> // Lowest priority<br>
> > > -                   NULL<br>
> > > -                   );<br>
> > > -  if (BestLanguage == NULL) {<br>
> > > -    goto Error;<br>
> > > +  if (TryBestLanguage) {<br>
> > > +    //<br>
> > > +    // Get the best matching language from SupportedLanguages<br>
> > > +    //<br>
> > > +    BestLanguage = GetBestLanguage (<br>
> > > +                     SupportedLanguages,<br>
> > > +                     FALSE,<br>
> // RFC 4646 mode<br>
> > > +                     Language,<br>
> // Highest priority<br>
> > > +                     PlatformLanguage != NULL ?<br>
> PlatformLanguage :<br>
> > > + "",  // Next<br>
> > > highest priority<br>
> > > +                     SupportedLanguages,<br>
> // Lowest priority<br>
> > > +                     NULL<br>
> > > +                     );<br>
> > > +    if (BestLanguage == NULL) {<br>
> > > +      goto Error;<br>
> > > +    }<br>
> > > +  } else {<br>
> > > +    BestLanguage = (CHAR8 *) Language;<br>
> > >    }<br>
> > ><br>
> > > +<br>
> > >    //<br>
> > >    // Retrieve the size of the string in the string package for the<br>
> > BestLanguage<br>
> > >    //<br>
> > > @@ -337,7 +383,7 @@ Error:<br>
> > >    if (PlatformLanguage != NULL) {<br>
> > >      FreePool (PlatformLanguage);<br>
> > >    }<br>
> > > -  if (BestLanguage != NULL) {<br>
> > > +  if (TryBestLanguage && BestLanguage != NULL) {<br>
> > >      FreePool (BestLanguage);<br>
> > >    }<br>
> > ><br>
> > > --<br>
> > > 2.17.1<br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> <br>
> <br>
> <br>
> <br>
> <br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
</span></font><br>
</div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr> Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/71190">View/Reply Online (#71190)</a> |    |  <a target="_blank" href="https://groups.io/mt/80375549/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>