msvcp90/msvcp90.h: right-hand operand of comma expression has no effect (PING)

Gerald Pfeifer gerald at pfeifer.com
Sat May 31 10:25:43 CDT 2014


On Wed, 16 Apr 2014, Paul Chitescu wrote:
>> Digging into this in more detail I see
>>
>>   ../msvcp90/ios.c: In function 'basic_streambuf_char__Xsgetn_s':
>>   ../msvcp90/msvcp90.h:529:75: warning: right-hand operand of comma
>> expression has no effect [-Wunused-value]
>>   #define memcpy_s( dst, size, src, count ) (memcpy( (dst), (src), (count)
>> ), 0) ^ ../msvcp90/ios.c:1218:13: note: in expansion of macro 'memcpy_s'
>> memcpy_s(ptr+copied, size, *this->prpos, chunk);
>>              ^
> memcpy_s() returns an errno_t so the author tried to force returning 
> zero (no error).

Since, clearly, the result is never intended to be used, we can as
well simply cast the result away instead of using ", 0".

This is what the patch below does.  Tested successfully with GCC 4.9.0.

Gerald

diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h
index 0d5e124..0691141 100644
--- a/dlls/msvcp90/msvcp90.h
+++ b/dlls/msvcp90/msvcp90.h
@@ -526,7 +526,7 @@ typedef struct {
 } complex_double;
 
 #if _MSVCP_VER < 80
-#define memcpy_s( dst, size, src, count ) (memcpy( (dst), (src), (count) ), 0)
+#define memcpy_s( dst, size, src, count ) ((void)memcpy( (dst), (src), (count) ))
 #define memmove_s( dst, size, src, count ) (memmove( (dst), (src), (count) ), 0)
 #define mbstowcs_s( ret, wcs, size, mbs, count ) (mbstowcs( (wcs), (mbs), (count) ), 0)
 #define hypotf( x, y ) ((float)hypot( (double)(x), (double)(y) ))



More information about the wine-patches mailing list