public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] CryptoPkg/IntrinsicLib: Fix the warning on memset
@ 2017-11-22  4:43 Gary Lin
  2017-11-22  8:10 ` Long, Qin
  0 siblings, 1 reply; 2+ messages in thread
From: Gary Lin @ 2017-11-22  4:43 UTC (permalink / raw)
  To: edk2-devel; +Cc: Qin Long, Ting Ye

Gcc issued the warning when compiling CryptoPkg:

CryptoPkg/Library/Include/CrtLibSupport.h:135:17: warning: type of 'memset' does not match original declaration [-Wlto-type-mismatch]
 void           *memset     (void *, int, size_t);
                 ^
CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c:27:8: note: type mismatch in parameter 2
 void * memset (void *dest, char ch, size_t count)
        ^

This commit changes the type of ch from char to int to match the
declaration.

Cc: Qin Long <qin.long@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Gary Lin <glin@suse.com>
---
 CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
index bf485d680d..e095f9aa0d 100644
--- a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
+++ b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
@@ -24,7 +24,7 @@ typedef UINTN  size_t;
 int _fltused = 1;
 
 /* Sets buffers to a specified character */
-void * memset (void *dest, char ch, size_t count)
+void * memset (void *dest, int ch, size_t count)
 {
   //
   // NOTE: Here we use one base implementation for memset, instead of the direct
@@ -42,7 +42,7 @@ void * memset (void *dest, char ch, size_t count)
 
   Pointer = (UINT8 *)dest;
   while (count-- != 0) {
-    *(Pointer++) = ch;
+    *(Pointer++) = (UINT8)ch;
   }
   
   return dest;
-- 
2.15.0



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

* Re: [PATCH] CryptoPkg/IntrinsicLib: Fix the warning on memset
  2017-11-22  4:43 [PATCH] CryptoPkg/IntrinsicLib: Fix the warning on memset Gary Lin
@ 2017-11-22  8:10 ` Long, Qin
  0 siblings, 0 replies; 2+ messages in thread
From: Long, Qin @ 2017-11-22  8:10 UTC (permalink / raw)
  To: Gary Lin, edk2-devel@lists.01.org; +Cc: Ye, Ting

Reviewed-by: Long Qin <qin.long@intel.com>

(Thanks, Gary. 
I cannot recall why we used "char" instead of "int" here. Obviously, the prototype of CRT memset should use "int").


Best Regards & Thanks,
LONG, Qin

-----Original Message-----
From: Gary Lin [mailto:glin@suse.com] 
Sent: Wednesday, November 22, 2017 12:44 PM
To: edk2-devel@lists.01.org
Cc: Long, Qin <qin.long@intel.com>; Ye, Ting <ting.ye@intel.com>
Subject: [PATCH] CryptoPkg/IntrinsicLib: Fix the warning on memset

Gcc issued the warning when compiling CryptoPkg:

CryptoPkg/Library/Include/CrtLibSupport.h:135:17: warning: type of 'memset' does not match original declaration [-Wlto-type-mismatch]
 void           *memset     (void *, int, size_t);
                 ^
CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c:27:8: note: type mismatch in parameter 2  void * memset (void *dest, char ch, size_t count)
        ^

This commit changes the type of ch from char to int to match the declaration.

Cc: Qin Long <qin.long@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Gary Lin <glin@suse.com>
---
 CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
index bf485d680d..e095f9aa0d 100644
--- a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
+++ b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
@@ -24,7 +24,7 @@ typedef UINTN  size_t;  int _fltused = 1;
 
 /* Sets buffers to a specified character */ -void * memset (void *dest, char ch, size_t count)
+void * memset (void *dest, int ch, size_t count)
 {
   //
   // NOTE: Here we use one base implementation for memset, instead of the direct @@ -42,7 +42,7 @@ void * memset (void *dest, char ch, size_t count)
 
   Pointer = (UINT8 *)dest;
   while (count-- != 0) {
-    *(Pointer++) = ch;
+    *(Pointer++) = (UINT8)ch;
   }
   
   return dest;
--
2.15.0



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

end of thread, other threads:[~2017-11-22  8:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-22  4:43 [PATCH] CryptoPkg/IntrinsicLib: Fix the warning on memset Gary Lin
2017-11-22  8:10 ` Long, Qin

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