[6737] Sparse fixes: truncation by cast
Revision: 6737
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6737 Author: blueswir1 Date: 2009-03-07 15:46:23 +0000 (Sat, 07 Mar 2009)
Log Message:
-----------
Sparse fixes: truncation by cast
Fix Sparse warnings about constant truncation caused by cast
Modified Paths:
--------------
trunk/bswap.h
trunk/hw/ide.c
trunk/hw/vga.c
trunk/tcg/x86_64/tcg-target.cModified: trunk/bswap.h
===================================================================
bswap.h +4 -4
@@ -151,7 +151,7 @@ {uint8_t *p1 = (uint8_t *)p; - p1[0 ] = v; + p1[0 ] = v &0xff ; p1[1 ] = v >>8 ; }
@@ -159,7 +159,7 @@ {uint8_t *p1 = (uint8_t *)p; - p1[0 ] = v; + p1[0 ] = v &0xff ; p1[1 ] = v >>8 ; p1[2 ] = v >>16 ; p1[3 ] = v >>24 ;
@@ -188,7 +188,7 @@uint8_t *p1 = (uint8_t *)p; p1[0 ] = v >>8 ; - p1[1 ] = v; + p1[1 ] = v &0xff ; }static inline void cpu_to_be32wu (uint32_t *p,uint32_t v)
@@ -198,7 +198,7 @@ p1[0 ] = v >>24 ; p1[1 ] = v >>16 ; p1[2 ] = v >>8 ; - p1[3] = v; + p1[3] = v & 0xff; }#endif
Modified: trunk/hw/ide.c
===================================================================
hw/ide.c +2 -2
@@ -1210,7 +1210,7 @@static inline void cpu_to_ube16 (uint8_t *buf,int val) { buf[0 ] = val >>8 ; - buf[1 ] = val; + buf[1 ] = val &0xff ; }static inline void cpu_to_ube32 (uint8_t *buf,unsigned int val)
@@ -1218,7 +1218,7 @@ buf[0 ] = val >>24 ; buf[1 ] = val >>16 ; buf[2 ] = val >>8 ; - buf[3 ] = val; + buf[3 ] = val &0xff ; }static inline int ube16_to_cpu (const uint8_t *buf)
Modified: trunk/hw/vga.c
===================================================================
hw/vga.c +24 -24
57 lines not on this page · raw message
Modified: trunk/tcg/x86_64/tcg-target.c
===================================================================
tcg/x86_64/tcg-target.c +1 -1
@@ -243,7 +243,7 @@ }if (opc &P_EXT )tcg_out8 (s,0x0f ); -tcg_out8 (s, opc); +tcg_out8 (s, opc &0xff ); }static inline void tcg_out_modrm (TCGContext *s,int opc,int r,int rm)
Quoted 15 lines · Blue Swirl
Revision: 6737
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6737
Author: blueswir1
Date: 2009-03-07 15:46:23 +0000 (Sat, 07 Mar 2009) Log Message:
-----------
Sparse fixes: truncation by castFix Sparse warnings about constant truncation caused by cast
Modified:
trunk/bswap.h
===================================================================
bswap.h 2009-03-07 15:46:23 UTC (rev 6737) line 155
Quoted 6 lines
bswap.h 2009-03-07 15:46:23 UTC (rev 6737) renamed from bswap.h 2009-03-07 15:32:56 UTC (rev 6736) +1
-1@@ -151,7 +151,7 @@ { uint8_t *p1 = (uint8_t *)p; - p1[0] = v; + p1[0] = v & 0xff; p1[1] = v >> 8;
Hum, by the same principle the last line should be:
p1[1] = (v >> 8) & 0xff;
no?
Luca
Quoted 20 lines · Luca Tettamanti
Quoted 19 lines · Blue Swirl
Revision: 6737
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6737 Author: blueswir1 Date: 2009-03-07 15:46:23 +0000 (Sat, 07 Mar 2009)Log Message:
-----------
Sparse fixes: truncation by castFix Sparse warnings about constant truncation caused by cast
Modified:
trunk/bswap.h
===================================================================bswap.h 2009-03-07 15:46:23 UTC (rev 6737) renamed from bswap.h 2009-03-07 15:32:56 UTC (rev 6736) +0
-0@@ -151,7 +151,7 @@ { uint8_t *p1 = (uint8_t *)p;
Quoted 8 lines
bswap.h 2009-03-07 15:46:23 UTC (rev 6737) line 155
Quoted 3 lines
bswap.h 2009-03-07 15:46:23 UTC (rev 6737) renamed from bswap.h 2009-03-07 15:32:56 UTC (rev 6736) +1
-1- p1[0] = v; + p1[0] = v & 0xff; p1[1] = v >> 8;Hum, by the same principle the last line should be:
p1[1] = (v >> 8) &0xff;
no?
Maybe and there would be other similar places, but there is no warning from Sparse except for this. Instead of "fix" I should have used something like "suppress" because the code wasn't broken, it's just that now Sparse is much more silent and real warnings are more visible from the noise.