Resolve cppcheck Signed integer overflow errors
The type of expression '1<<31' is signed int and this causes cppcheck to issue the following warning. src/gf_w32.c:681]: (error) Signed integer overflow for expression '1<<31'. Signed-off-by: Brad Hubbard <bhubbard@redhat.com>master
parent
ea75cdffe1
commit
2700e1b9ae
|
@ -14,7 +14,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#define GF_FIELD_WIDTH (32)
|
||||
#define GF_FIRST_BIT (1 << 31)
|
||||
#define GF_FIRST_BIT ((gf_val_32_t)1 << 31)
|
||||
|
||||
#define GF_BASE_FIELD_WIDTH (16)
|
||||
#define GF_BASE_FIELD_SIZE (1 << GF_BASE_FIELD_WIDTH)
|
||||
|
|
|
@ -137,7 +137,7 @@ int gf_general_s_to_val(gf_general_t *v, int w, char *s, int hex)
|
|||
}
|
||||
if (w == 32) return 1;
|
||||
if (w == 31) {
|
||||
if (v->w32 & (1 << 31)) return 0;
|
||||
if (v->w32 & ((gf_val_32_t)1 << 31)) return 0;
|
||||
return 1;
|
||||
}
|
||||
if (v->w32 & ~((1 << w)-1)) return 0;
|
||||
|
|
|
@ -413,7 +413,7 @@ gf_w128_sse_bytwo_p_multiply(gf_t *gf, gf_val_128_t a128, gf_val_128_t b128, gf_
|
|||
}
|
||||
amask = _mm_srli_epi64(amask, 1); /*so does this one, but we can just replace after loop*/
|
||||
}
|
||||
amask = _mm_insert_epi32(amask, 1 << 31, 0x1);
|
||||
amask = _mm_insert_epi32(amask, (gf_val_32_t)1 << 31, 0x1);
|
||||
for (i = 64; i < 128; i++) {
|
||||
topbit = (_mm_extract_epi32(prod, 0x3) & pmask);
|
||||
middlebit = (_mm_extract_epi32(prod, 0x1) & pmask);
|
||||
|
|
|
@ -1079,7 +1079,7 @@ gf_w32_bytwo_p_sse_multiply_region(gf_t *gf, void *src, void *dest, gf_val_32_t
|
|||
vrev = 0;
|
||||
for (i = 0; i < 32; i++) {
|
||||
vrev <<= 1;
|
||||
if (!(val & (1 << i))) vrev |= 1;
|
||||
if (!(val & ((gf_val_32_t)1 << i))) vrev |= 1;
|
||||
}
|
||||
|
||||
s8 = (uint8_t *) rd.s_start;
|
||||
|
|
Loading…
Reference in New Issue