[edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer

Paolo Bonzini posted 1 patch 7 years, 8 months ago
Failed in applying to current master (apply log)
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer
Posted by Paolo Bonzini 7 years, 8 months ago
This would be valid C but is not valid C++, so change the comparison
to do what it has always been doing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 3ca57ed..2f97975 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -3372,7 +3372,7 @@ CVfrStringDB::GetVarStoreNameFormStringId (
   UINT8       BlockType;
   EFI_HII_STRING_PACKAGE_HDR *PkgHeader;
   
-  if (mStringFileName == '\0' ) {
+  if (mStringFileName == NULL) {
     return NULL;
   }
 
-- 
2.9.3

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer
Posted by Zhu, Yonghong 7 years, 8 months ago
Hi Paolo Bonzini,

We already had another patch for this issue.  Please help to check the attachment. Thanks.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Paolo Bonzini [mailto:pbonzini@redhat.com] 
Sent: Monday, February 13, 2017 8:54 PM
To: edk2-devel@ml01.01.org
Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH] VfrCompile: fix invalid comparison between pointer and integer

This would be valid C but is not valid C++, so change the comparison to do what it has always been doing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 3ca57ed..2f97975 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -3372,7 +3372,7 @@ CVfrStringDB::GetVarStoreNameFormStringId (
   UINT8       BlockType;
   EFI_HII_STRING_PACKAGE_HDR *PkgHeader;
   
-  if (mStringFileName == '\0' ) {
+  if (mStringFileName == NULL) {
     return NULL;
   }
 
--
2.9.3

From: Nikolai SAOUKH <nms@otdel-1.org>

GCC7 complaint -- error: ISO C++ forbids comparison between pointer and
integer.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Nikolai SAOUKH <nms@otdel-1.org>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 3ca57ed..b81fc7b 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -3370,11 +3370,11 @@ CVfrStringDB::GetVarStoreNameFormStringId (
   EFI_STATUS  Status;
   CHAR8       LineBuf[EFI_IFR_MAX_LENGTH];
   UINT8       BlockType;
   EFI_HII_STRING_PACKAGE_HDR *PkgHeader;

-  if (mStringFileName == '\0' ) {
+  if (mStringFileName == NULL || *mStringFileName == '\0' ) {
     return NULL;
   }

   if ((pInFile = fopen (LongFilePath (mStringFileName), "rb")) == NULL) {
     return NULL;
--
2.6.1.windows.1

_______________________________________________
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
Re: [edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer
Posted by Paolo Bonzini 7 years, 8 months ago

On 13/02/2017 14:55, Zhu, Yonghong wrote:
> Hi Paolo Bonzini,
> 
> We already had another patch for this issue.  Please help to check the attachment. Thanks.

Is it intended that "-s ''" is not an error, rather it is the same as no
option at all?

Paolo

> Best Regards,
> Zhu Yonghong
> 
> 
> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com] 
> Sent: Monday, February 13, 2017 8:54 PM
> To: edk2-devel@ml01.01.org
> Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [PATCH] VfrCompile: fix invalid comparison between pointer and integer
> 
> This would be valid C but is not valid C++, so change the comparison to do what it has always been doing.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> index 3ca57ed..2f97975 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> @@ -3372,7 +3372,7 @@ CVfrStringDB::GetVarStoreNameFormStringId (
>    UINT8       BlockType;
>    EFI_HII_STRING_PACKAGE_HDR *PkgHeader;
>    
> -  if (mStringFileName == '\0' ) {
> +  if (mStringFileName == NULL) {
>      return NULL;
>    }
>  
> --
> 2.9.3
> 
> 
> 
> _______________________________________________
> 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
Re: [edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer
Posted by Zhu, Yonghong 7 years, 8 months ago
Hi Paolo,

"-s ''" is an error, current the error message is not same as no option, because the content after the " all be treated as -s 's input.
May I know what's your comment on  Nikolai SAOUKH's patch ?

-  if (mStringFileName == '\0' ) {
+  if (mStringFileName == NULL || *mStringFileName == '\0' ) {


Best Regards,
Zhu Yonghong


-----Original Message-----
From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini
Sent: Monday, February 13, 2017 10:18 PM
To: Zhu, Yonghong <yonghong.zhu@intel.com>; edk2-devel@ml01.01.org
Cc: Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer



On 13/02/2017 14:55, Zhu, Yonghong wrote:
> Hi Paolo Bonzini,
> 
> We already had another patch for this issue.  Please help to check the attachment. Thanks.

Is it intended that "-s ''" is not an error, rather it is the same as no option at all?

Paolo

> Best Regards,
> Zhu Yonghong
> 
> 
> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Monday, February 13, 2017 8:54 PM
> To: edk2-devel@ml01.01.org
> Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming 
> <liming.gao@intel.com>
> Subject: [PATCH] VfrCompile: fix invalid comparison between pointer 
> and integer
> 
> This would be valid C but is not valid C++, so change the comparison to do what it has always been doing.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp 
> b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> index 3ca57ed..2f97975 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> @@ -3372,7 +3372,7 @@ CVfrStringDB::GetVarStoreNameFormStringId (
>    UINT8       BlockType;
>    EFI_HII_STRING_PACKAGE_HDR *PkgHeader;
>    
> -  if (mStringFileName == '\0' ) {
> +  if (mStringFileName == NULL) {
>      return NULL;
>    }
>  
> --
> 2.9.3
> 
> 
> 
> _______________________________________________
> 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
Re: [edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer
Posted by Paolo Bonzini 7 years, 8 months ago

On 15/02/2017 09:46, Zhu, Yonghong wrote:
> 
> "-s ''" is an error, current the error message is not same as no option, because the content after the " all be treated as -s 's input.
> May I know what's your comment on  Nikolai SAOUKH's patch ?
> 
> -  if (mStringFileName == '\0' ) {
> +  if (mStringFileName == NULL || *mStringFileName == '\0' ) {

If "-s ''" is an error, it should be pointless to check *mStringFileName.

Paolo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer
Posted by Zhu, Yonghong 7 years, 8 months ago
Hi Paolo,

Yes, I agree with you.  I also add Nikolai SAOUKH in loop in case he may have different comment.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini
Sent: Wednesday, February 15, 2017 5:11 PM
To: Zhu, Yonghong <yonghong.zhu@intel.com>; edk2-devel@ml01.01.org
Cc: Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2] [PATCH] VfrCompile: fix invalid comparison between pointer and integer



On 15/02/2017 09:46, Zhu, Yonghong wrote:
> 
> "-s ''" is an error, current the error message is not same as no option, because the content after the " all be treated as -s 's input.
> May I know what's your comment on  Nikolai SAOUKH's patch ?
> 
> -  if (mStringFileName == '\0' ) {
> +  if (mStringFileName == NULL || *mStringFileName == '\0' ) {

If "-s ''" is an error, it should be pointless to check *mStringFileName.

Paolo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel