public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] Fix a couple of build errors in BaseTools when using gcc 8
@ 2018-05-28  3:28 Rebecca Cran
  2018-05-28  3:34 ` Rebecca Cran
  0 siblings, 1 reply; 3+ messages in thread
From: Rebecca Cran @ 2018-05-28  3:28 UTC (permalink / raw)
  To: edk2-devel, Yonghong Zhu, Liming Gao

---
 BaseTools/Source/C/GenVtf/GenVtf.c              | 2 +-
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c
index 6f66ddc84..4d87e1c8c 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -1470,7 +1470,7 @@ Returns:
   //
   FitStartPtr = (FIT_TABLE *) RelativeAddress;
 
-  strncpy ((CHAR8 *) &FitStartPtr->CompAddress, FIT_SIGNATURE, 8);  // "_FIT_   "
+  memcpy(&FitStartPtr->CompAddress, FIT_SIGNATURE, 8); // "_FIT_   "
   assert (((VtfInfo->CompSize & 0x00FFFFFF) % 16) == 0);
   FitStartPtr->CompSize     = (VtfInfo->CompSize & 0x00FFFFFF) / 16;
   FitStartPtr->CompVersion  = MAKE_VERSION (VtfInfo->MajorVer, VtfInfo->MinorVer);
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index f73b70d79..73a318724 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -3284,7 +3284,7 @@ CVfrStringDB::GetVarStoreNameFormStringId (
   UINT8       BlockType;
   EFI_HII_STRING_PACKAGE_HDR *PkgHeader;
   
-  if (mStringFileName == '\0' ) {
+  if (*mStringFileName == '\0' ) {
     return NULL;
   }
 
-- 
2.17.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix a couple of build errors in BaseTools when using gcc 8
  2018-05-28  3:28 [PATCH] Fix a couple of build errors in BaseTools when using gcc 8 Rebecca Cran
@ 2018-05-28  3:34 ` Rebecca Cran
  2018-05-28  3:48   ` Rebecca Cran
  0 siblings, 1 reply; 3+ messages in thread
From: Rebecca Cran @ 2018-05-28  3:34 UTC (permalink / raw)
  To: edk2-devel, Yonghong Zhu, Liming Gao

On 05/27/18 21:28, Rebecca Cran wrote:
> ---
>  BaseTools/Source/C/GenVtf/GenVtf.c              | 2 +-
>  BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c
> index 6f66ddc84..4d87e1c8c 100644
> --- a/BaseTools/Source/C/GenVtf/GenVtf.c
> +++ b/BaseTools/Source/C/GenVtf/GenVtf.c
> @@ -1470,7 +1470,7 @@ Returns:
>    //
>    FitStartPtr = (FIT_TABLE *) RelativeAddress;
>  
> -  strncpy ((CHAR8 *) &FitStartPtr->CompAddress, FIT_SIGNATURE, 8);  // "_FIT_   "
> +  memcpy(&FitStartPtr->CompAddress, FIT_SIGNATURE, 8); // "_FIT_   "
>    assert (((VtfInfo->CompSize & 0x00FFFFFF) % 16) == 0);
>    FitStartPtr->CompSize     = (VtfInfo->CompSize & 0x00FFFFFF) / 16;
>    FitStartPtr->CompVersion  = MAKE_VERSION (VtfInfo->MajorVer, VtfInfo->MinorVer);
> diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> index f73b70d79..73a318724 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> @@ -3284,7 +3284,7 @@ CVfrStringDB::GetVarStoreNameFormStringId (
>    UINT8       BlockType;
>    EFI_HII_STRING_PACKAGE_HDR *PkgHeader;
>    
> -  if (mStringFileName == '\0' ) {
> +  if (*mStringFileName == '\0' ) {
>      return NULL;
>    }
>  
> 

The change from strncpy to memcpy is because from the length argument it
appears that the contents of "CompAddress" shouldn't be NUL-terminated.

The change to the comparison is because mStringFileName is a pointer,
and comparing it against '\0' doesn't make sense. It seems the author
meant for the first character to be compared against NUL.

-- 
Rebecca Cran


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix a couple of build errors in BaseTools when using gcc 8
  2018-05-28  3:34 ` Rebecca Cran
@ 2018-05-28  3:48   ` Rebecca Cran
  0 siblings, 0 replies; 3+ messages in thread
From: Rebecca Cran @ 2018-05-28  3:48 UTC (permalink / raw)
  To: edk2-devel, Yonghong Zhu, Liming Gao

On 05/27/18 21:34, Rebecca Cran wrote:

> The change from strncpy to memcpy is because from the length argument it
> appears that the contents of "CompAddress" shouldn't be NUL-terminated.
> 
> The change to the comparison is because mStringFileName is a pointer,
> and comparing it against '\0' doesn't make sense. It seems the author
> meant for the first character to be compared against NUL.
> 

Sorry, please ignore this: I was working against a tree that was last
updated in 2015, so this patch isn't applicable.

-- 
Rebecca Cran


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-28  3:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-28  3:28 [PATCH] Fix a couple of build errors in BaseTools when using gcc 8 Rebecca Cran
2018-05-28  3:34 ` Rebecca Cran
2018-05-28  3:48   ` Rebecca Cran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox