Commit 9e622b15a3fb4872a1424f2717dc956da18e473d
1 parent
511d2b14
Sparse fixes: truncation by cast
Fix Sparse warnings about constant truncation caused by cast git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6737 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
31 additions
and
31 deletions
bswap.h
... | ... | @@ -151,7 +151,7 @@ static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) |
151 | 151 | { |
152 | 152 | uint8_t *p1 = (uint8_t *)p; |
153 | 153 | |
154 | - p1[0] = v; | |
154 | + p1[0] = v & 0xff; | |
155 | 155 | p1[1] = v >> 8; |
156 | 156 | } |
157 | 157 | |
... | ... | @@ -159,7 +159,7 @@ static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) |
159 | 159 | { |
160 | 160 | uint8_t *p1 = (uint8_t *)p; |
161 | 161 | |
162 | - p1[0] = v; | |
162 | + p1[0] = v & 0xff; | |
163 | 163 | p1[1] = v >> 8; |
164 | 164 | p1[2] = v >> 16; |
165 | 165 | p1[3] = v >> 24; |
... | ... | @@ -188,7 +188,7 @@ static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) |
188 | 188 | uint8_t *p1 = (uint8_t *)p; |
189 | 189 | |
190 | 190 | p1[0] = v >> 8; |
191 | - p1[1] = v; | |
191 | + p1[1] = v & 0xff; | |
192 | 192 | } |
193 | 193 | |
194 | 194 | static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) |
... | ... | @@ -198,7 +198,7 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) |
198 | 198 | p1[0] = v >> 24; |
199 | 199 | p1[1] = v >> 16; |
200 | 200 | p1[2] = v >> 8; |
201 | - p1[3] = v; | |
201 | + p1[3] = v & 0xff; | |
202 | 202 | } |
203 | 203 | |
204 | 204 | #endif | ... | ... |
hw/ide.c
... | ... | @@ -1210,7 +1210,7 @@ static void ide_atapi_cmd_check_status(IDEState *s) |
1210 | 1210 | static inline void cpu_to_ube16(uint8_t *buf, int val) |
1211 | 1211 | { |
1212 | 1212 | buf[0] = val >> 8; |
1213 | - buf[1] = val; | |
1213 | + buf[1] = val & 0xff; | |
1214 | 1214 | } |
1215 | 1215 | |
1216 | 1216 | static inline void cpu_to_ube32(uint8_t *buf, unsigned int val) |
... | ... | @@ -1218,7 +1218,7 @@ static inline void cpu_to_ube32(uint8_t *buf, unsigned int val) |
1218 | 1218 | buf[0] = val >> 24; |
1219 | 1219 | buf[1] = val >> 16; |
1220 | 1220 | buf[2] = val >> 8; |
1221 | - buf[3] = val; | |
1221 | + buf[3] = val & 0xff; | |
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | static inline int ube16_to_cpu(const uint8_t *buf) | ... | ... |
hw/vga.c
... | ... | @@ -38,33 +38,33 @@ |
38 | 38 | |
39 | 39 | /* force some bits to zero */ |
40 | 40 | const uint8_t sr_mask[8] = { |
41 | - (uint8_t)~0xfc, | |
42 | - (uint8_t)~0xc2, | |
43 | - (uint8_t)~0xf0, | |
44 | - (uint8_t)~0xc0, | |
45 | - (uint8_t)~0xf1, | |
46 | - (uint8_t)~0xff, | |
47 | - (uint8_t)~0xff, | |
48 | - (uint8_t)~0x00, | |
41 | + 0x03, | |
42 | + 0x3d, | |
43 | + 0x0f, | |
44 | + 0x3f, | |
45 | + 0x0e, | |
46 | + 0x00, | |
47 | + 0x00, | |
48 | + 0xff, | |
49 | 49 | }; |
50 | 50 | |
51 | 51 | const uint8_t gr_mask[16] = { |
52 | - (uint8_t)~0xf0, /* 0x00 */ | |
53 | - (uint8_t)~0xf0, /* 0x01 */ | |
54 | - (uint8_t)~0xf0, /* 0x02 */ | |
55 | - (uint8_t)~0xe0, /* 0x03 */ | |
56 | - (uint8_t)~0xfc, /* 0x04 */ | |
57 | - (uint8_t)~0x84, /* 0x05 */ | |
58 | - (uint8_t)~0xf0, /* 0x06 */ | |
59 | - (uint8_t)~0xf0, /* 0x07 */ | |
60 | - (uint8_t)~0x00, /* 0x08 */ | |
61 | - (uint8_t)~0xff, /* 0x09 */ | |
62 | - (uint8_t)~0xff, /* 0x0a */ | |
63 | - (uint8_t)~0xff, /* 0x0b */ | |
64 | - (uint8_t)~0xff, /* 0x0c */ | |
65 | - (uint8_t)~0xff, /* 0x0d */ | |
66 | - (uint8_t)~0xff, /* 0x0e */ | |
67 | - (uint8_t)~0xff, /* 0x0f */ | |
52 | + 0x0f, /* 0x00 */ | |
53 | + 0x0f, /* 0x01 */ | |
54 | + 0x0f, /* 0x02 */ | |
55 | + 0x1f, /* 0x03 */ | |
56 | + 0x03, /* 0x04 */ | |
57 | + 0x7b, /* 0x05 */ | |
58 | + 0x0f, /* 0x06 */ | |
59 | + 0x0f, /* 0x07 */ | |
60 | + 0xff, /* 0x08 */ | |
61 | + 0x00, /* 0x09 */ | |
62 | + 0x00, /* 0x0a */ | |
63 | + 0x00, /* 0x0b */ | |
64 | + 0x00, /* 0x0c */ | |
65 | + 0x00, /* 0x0d */ | |
66 | + 0x00, /* 0x0e */ | |
67 | + 0x00, /* 0x0f */ | |
68 | 68 | }; |
69 | 69 | |
70 | 70 | #define cbswap_32(__x) \ | ... | ... |
tcg/x86_64/tcg-target.c
... | ... | @@ -243,7 +243,7 @@ static inline void tcg_out_opc(TCGContext *s, int opc, int r, int rm, int x) |
243 | 243 | } |
244 | 244 | if (opc & P_EXT) |
245 | 245 | tcg_out8(s, 0x0f); |
246 | - tcg_out8(s, opc); | |
246 | + tcg_out8(s, opc & 0xff); | |
247 | 247 | } |
248 | 248 | |
249 | 249 | static inline void tcg_out_modrm(TCGContext *s, int opc, int r, int rm) | ... | ... |