public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] NetworkPkg/HttpDxe: Fix build warning error if CHAR8 is unsigned.
@ 2018-01-02  3:33 Jiaxin Wu
  2018-01-09  1:17 ` Fu, Siyuan
  0 siblings, 1 reply; 2+ messages in thread
From: Jiaxin Wu @ 2018-01-02  3:33 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Michael Kinney, Wu Jiaxin

This patch is to fix the compiler warning error: C4245. The issue will happen
if the below build option is enabled:
  *_*_*_CC_FLAGS = -J.

That's because the value of ('A' - 'a') is a negative value, which will
be converted to an unsigned type if CHAR8 is treated as unsigned:
  Src -= ('A' - 'a');

The above issue is also recorded at:
https://bugzilla.tianocore.org/show_bug.cgi?id=815.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/HttpDxe/HttpsSupport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c b/NetworkPkg/HttpDxe/HttpsSupport.c
index e6f4d5a..6aed61a 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -65,15 +65,15 @@ AsciiStrCaseStr (
             && (*String != '\0')) {
       Src = *String;
       Dst = *SearchStringTmp;
 
       if ((Src >= 'A') && (Src <= 'Z')) {
-        Src -= ('A' - 'a');
+        Src += ('a' - 'A');
       }
 
       if ((Dst >= 'A') && (Dst <= 'Z')) {
-        Dst -= ('A' - 'a');
+        Dst += ('a' - 'A');
       }
 
       if (Src != Dst) {
         break;
       }
-- 
1.9.5.msysgit.1



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

* Re: [Patch] NetworkPkg/HttpDxe: Fix build warning error if CHAR8 is unsigned.
  2018-01-02  3:33 [Patch] NetworkPkg/HttpDxe: Fix build warning error if CHAR8 is unsigned Jiaxin Wu
@ 2018-01-09  1:17 ` Fu, Siyuan
  0 siblings, 0 replies; 2+ messages in thread
From: Fu, Siyuan @ 2018-01-09  1:17 UTC (permalink / raw)
  To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Kinney, Michael D



Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>

> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Tuesday, January 2, 2018 11:34 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [Patch] NetworkPkg/HttpDxe: Fix build warning error if CHAR8 is
> unsigned.
> 
> This patch is to fix the compiler warning error: C4245. The issue will
> happen
> if the below build option is enabled:
>   *_*_*_CC_FLAGS = -J.
> 
> That's because the value of ('A' - 'a') is a negative value, which will
> be converted to an unsigned type if CHAR8 is treated as unsigned:
>   Src -= ('A' - 'a');
> 
> The above issue is also recorded at:
> https://bugzilla.tianocore.org/show_bug.cgi?id=815.
> 
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
>  NetworkPkg/HttpDxe/HttpsSupport.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c
> b/NetworkPkg/HttpDxe/HttpsSupport.c
> index e6f4d5a..6aed61a 100644
> --- a/NetworkPkg/HttpDxe/HttpsSupport.c
> +++ b/NetworkPkg/HttpDxe/HttpsSupport.c
> @@ -65,15 +65,15 @@ AsciiStrCaseStr (
>              && (*String != '\0')) {
>        Src = *String;
>        Dst = *SearchStringTmp;
> 
>        if ((Src >= 'A') && (Src <= 'Z')) {
> -        Src -= ('A' - 'a');
> +        Src += ('a' - 'A');
>        }
> 
>        if ((Dst >= 'A') && (Dst <= 'Z')) {
> -        Dst -= ('A' - 'a');
> +        Dst += ('a' - 'A');
>        }
> 
>        if (Src != Dst) {
>          break;
>        }
> --
> 1.9.5.msysgit.1



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

end of thread, other threads:[~2018-01-09  1:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-02  3:33 [Patch] NetworkPkg/HttpDxe: Fix build warning error if CHAR8 is unsigned Jiaxin Wu
2018-01-09  1:17 ` Fu, Siyuan

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