Fix some warnings

This commit is contained in:
Patrick Pelissier committed 2020-07-09 23:38:34 +02:00
1 parent 8a36b5ff15
commit 56d2a74818
11 files changed
+37 -36

No files matched your search

+2 -2
View File
@@ -1913,11 +1913,11 @@ static inline uint64_t m_core_roundpow2(uint64_t v)
#if defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__) >= 304
static inline unsigned int m_core_clz32(uint32_t limb)
{
return M_UNLIKELY (limb == 0) ? sizeof(uint32_t)*CHAR_BIT : (unsigned int) __builtin_clzl(limb) - (sizeof(unsigned long) - sizeof(uint32_t)) * CHAR_BIT;
return (unsigned int) (M_UNLIKELY (limb == 0) ? sizeof(uint32_t)*CHAR_BIT : (size_t) __builtin_clzl(limb) - (sizeof(unsigned long) - sizeof(uint32_t)) * CHAR_BIT);
}
static inline unsigned int m_core_clz64(uint64_t limb)
{
return M_UNLIKELY (limb == 0ULL) ? sizeof (uint64_t)*CHAR_BIT : (unsigned int) __builtin_clzll(limb) - (sizeof (unsigned long long) - sizeof (uint64_t)) * CHAR_BIT;
return (unsigned int) (M_UNLIKELY (limb == 0ULL) ? sizeof (uint64_t)*CHAR_BIT : (size_t) __builtin_clzll(limb) - (sizeof (unsigned long long) - sizeof (uint64_t)) * CHAR_BIT);
}
#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64))
+4 -4
View File
@@ -1212,8 +1212,8 @@ typedef enum {
static inline void \
M_C(name,_int_limit)(dict_t dict, size_t size) \
{ \
dict->upper_limit = (size_t) (size * coeff_up) - 1; \
dict->lower_limit = (size <= DICTI_INITIAL_SIZE) ? 0 : (size_t) (size * coeff_down) ; \
dict->upper_limit = (size_t) ((double) size * coeff_up) - 1; \
dict->lower_limit = (size <= DICTI_INITIAL_SIZE) ? 0 : (size_t) ((double) size * coeff_down) ; \
} \
\
static inline void \
@@ -1856,14 +1856,14 @@ typedef enum {
DICTI_OA_CONTRACT(dict); \
size_t size; \
/* Get the size which will allow to fit this capacity */ \
size = m_core_roundpow2 ((uint64_t) (capacity * (1.0 / coeff_up))); \
size = m_core_roundpow2 ((uint64_t) ((double) capacity * (1.0 / coeff_up))); \
/* Test for overflow of the computation */ \
if (M_UNLIKELY (size < capacity)) { \
M_MEMORY_FULL((size_t)-1); \
} \
assert (M_POWEROF2_P(size)); \
if (size > dict->mask+1) { \
dict->upper_limit = (size_t) (size * coeff_up) - 1; \
dict->upper_limit = (size_t) ((double) size * coeff_up) - 1; \
M_C(name,_int_resize_up)(dict, size, false); \
} \
DICTI_OA_CONTRACT(dict); \
+1 -1
View File
@@ -64,7 +64,7 @@ typedef struct genint_s {
#define GENINT_MAX_ALLOC (GENINT_LIMBSIZE * (GENINT_LIMBSIZE - GENINT_ABA_CPT))
// Define the size of a limb in bits.
#define GENINT_LIMBSIZE (sizeof(genint_limb_t) * CHAR_BIT)
#define GENINT_LIMBSIZE ((unsigned)(sizeof(genint_limb_t) * CHAR_BIT))
// Define the contract of a genint
#define GENINT_CONTRACT(s) do { \
+8 -8
View File
@@ -326,7 +326,7 @@ typedef enum {
} else { \
/* go left (if cmp > 0) or right (if cmp < 0) */ \
int s = (cmp < 0); \
which[cpt++] = s; \
which[cpt++] = (int8_t) s; \
n = n->child[s]; \
} \
/* We cannot overflow the max depth of a tree */ \
@@ -433,13 +433,13 @@ typedef enum {
assert (child == 0 || child == 1); \
unsigned int cpt = 0; \
if (tree->node != NULL) { \
it->which[cpt] = child; \
it->which[cpt] = (int8_t) child; \
node_t *n = it->stack[cpt++] = tree->node; \
/* Go down the tree and fill in the iterator */ \
while (n->child[child] != NULL) { \
assert (cpt < RBTREEI_MAX_STACK); \
n = n->child[child]; \
it->which[cpt] = child; \
it->which[cpt] = (int8_t) child; \
it->stack[cpt++] = n; \
} \
assert (n == it->stack[cpt - 1]); \
@@ -496,14 +496,14 @@ typedef enum {
/* Going right */ \
assert (cpt < RBTREEI_MAX_STACK); \
n = n->child[right]; \
it->which[cpt++] = right; \
it->which[cpt++] = (int8_t) right; \
it->stack[cpt] = n; \
it->which[cpt++] = child; \
it->which[cpt++] = (int8_t) child; \
/* Going left */ \
while (n->child[child] != NULL) { \
assert (cpt < RBTREEI_MAX_STACK); \
n = n->child[child]; \
it->which[cpt] = child; \
it->which[cpt] = (int8_t) child; \
it->stack[cpt++] = n; \
} \
assert (n == it->stack[cpt - 1]); \
@@ -562,7 +562,7 @@ typedef enum {
if (cmp == 0) \
break; \
int child = (cmp < 0); \
it->which[cpt++] = child; \
it->which[cpt++] = (int8_t) child; \
n = n->child[child]; \
assert (cpt < RBTREEI_MAX_STACK); \
it->stack[cpt] = n; \
@@ -800,7 +800,7 @@ typedef enum {
break; \
} \
int i = (cmp < 0); \
which[cpt++] = i; \
which[cpt++] = (int8_t) i; \
n = n->child[i]; \
assert (cpt < RBTREEI_MAX_STACK); \
tab[cpt] = n; \
+6 -6
View File
@@ -1100,9 +1100,9 @@ string_get_str(string_t v, const string_t v2, bool append)
ptr = stringi_fit2size(v, targetSize);
int d1 = c & 0x07, d2 = (c>>3) & 0x07, d3 = (c>>6) & 0x07;
ptr[size ++] = '\\';
ptr[size ++] = '0' + d3;
ptr[size ++] = '0' + d2;
ptr[size ++] = '0' + d1;
ptr[size ++] = (char) ('0' + d3);
ptr[size ++] = (char) ('0' + d2);
ptr[size ++] = (char) ('0' + d1);
} else {
ptr[size ++] = c;
}
@@ -1193,7 +1193,7 @@ string_in_str(string_t v, FILE *f)
break;
}
}
string_push_back (v, c);
string_push_back (v, (char) c);
c = fgetc(f);
}
return c == '"';
@@ -1243,7 +1243,7 @@ string_parse_str(string_t v, const char str[], const char **endptr)
break;
}
}
string_push_back (v, c);
string_push_back (v, (char) c);
c = *str++;
}
success = (c == '"');
@@ -1326,7 +1326,7 @@ static inline void
stringi_utf8_decode(char c, stringi_utf8_state_e *state,
string_unicode_t *unicode)
{
const unsigned int type = m_core_clz32((unsigned char)~c) - (sizeof(uint32_t) - 1) * CHAR_BIT;
const unsigned int type = m_core_clz32((unsigned char)~c) - (unsigned) (sizeof(uint32_t) - 1) * CHAR_BIT;
const string_unicode_t mask1 = (UINT_MAX - (string_unicode_t)(*state != STRINGI_UTF8_STARTING) + 1);
const string_unicode_t mask2 = (0xFFU >> type);
*unicode = ((*unicode << 6) & mask1) | ((unsigned int) c & mask2);
+2 -2
View File
@@ -501,7 +501,7 @@
/* First read the name of the type */ \
c = *str++; \
while (c != '@' && c != 0 && i < sizeof(variantTypeBuf) - 1) { \
variantTypeBuf[i++] = c; \
variantTypeBuf[i++] = (char) c; \
c = *str++; \
} \
if (c != '@') goto exit; \
@@ -559,7 +559,7 @@
int c = fgetc(f); \
unsigned int i = 0; \
while (c != '@' && c != EOF && i < sizeof(variantTypeBuf) - 1) { \
variantTypeBuf[i++] = c; \
variantTypeBuf[i++] = (char) c; \
c = fgetc(f); \
} \
if (c != '@') return false; \
+1 -1
View File
@@ -192,7 +192,7 @@ workeri_get_cpu_count(void)
sysctl(nm, 2, &count, &len, NULL, 0);
return M_MAX(1, count);
#elif defined (_SC_NPROCESSORS_ONLN)
return sysconf(_SC_NPROCESSORS_ONLN);
return (int) sysconf(_SC_NPROCESSORS_ONLN);
#else
return 1;
#endif
+2 -2
View File
@@ -21,8 +21,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CC=cc -std=c99
WCFLAGS_GCC=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wunused-function -ftrapv -Wsign-conversion
WCFLAGS_CLANG=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wunused-function -ftrapv -Wsign-conversion
WCFLAGS_GCC=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wunused-function -ftrapv -Wsign-conversion -Wdate-time -Wconversion -Wformat=2 -Winit-self -Wjump-misses-init -Wstack-protector -Wtrampolines -Wwrite-strings -Wformat-security
WCFLAGS_CLANG=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wunused-function -ftrapv -Wsign-conversion
WCFLAGS_CPP=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wstrict-overflow=5 -Winline -Wundef -Wcast-qual -Wshadow -Wunreachable-code -Wstrict-aliasing=2 -Wredundant-decls -Wunused-function -ftrapv -Wsign-conversion
XCFLAGS=
CFLAGS=$(WCFLAGS_GCC) $(XCFLAGS)
+4 -3
View File
@@ -179,7 +179,7 @@ static void test_stack2(void)
char c;
buffer_char_init(buff, 10);
for(int i = 0; i < 10; i++) {
c = i;
c = (char) i;
b = buffer_char_push(buff, c);
assert (b == true);
assert (buffer_char_empty_p(buff) == false);
@@ -307,8 +307,9 @@ static void test_prod(void *arg)
assert (arg == NULL);
for(unsigned int i = 0; i < 10;i++) {
test_t *p = test_new();
for(int j = 0; j < 52; j++)
p->buffer[j] = (j * j * 17) + j * 42 + 1;
for(int j = 0; j < 52; j++) {
p->buffer[j] = (char) ((j * j * 17) + j * 42 + 1);
}
buffer_itest_push(comm1, p);
buffer_itest_push(comm2, p);
ishared_itest_clear(p);
+6 -6
View File
@@ -469,14 +469,14 @@ static void test_builtin(void)
{
assert(m_core_clz32(0) == 32);
for(unsigned i = 0; i < 31; i++) {
assert(m_core_clz32(1UL<<i) == 31U - i);
assert(m_core_clz32((1UL<<i) | 1) == 31U - i);
assert(m_core_clz32((uint32_t) (1UL<<i)) == 31U - i);
assert(m_core_clz32((uint32_t) ((1UL<<i) | 1)) == 31U - i);
}
assert(m_core_clz64(0) == 64);
for(unsigned i = 0; i < 63; i++) {
assert(m_core_clz64(1ULL<<i) == 63U - i);
assert(m_core_clz64((1ULL<<i) | 1) == 63U - i);
assert(m_core_clz64((uint64_t) (1ULL<<i)) == 63U - i);
assert(m_core_clz64((uint64_t) ((1ULL<<i) | 1)) == 63U - i);
}
assert ( m_core_roundpow2(0) == 0);
@@ -488,8 +488,8 @@ static void test_builtin(void)
for(unsigned i = 0; i < 3000; i++) {
assert( m_core_rotl32a(i, 1) == i * 2);
assert( m_core_rotl32a(i, 2) == i * 4);
assert( m_core_rotl32a((1UL<<31) + i, 1) == i * 2 + 1);
assert( m_core_rotl32a((1UL<<31) + i, 2) == i * 4 + 2);
assert( m_core_rotl32a((uint32_t) ((1UL<<31) + i), 1) == i * 2 + 1);
assert( m_core_rotl32a((uint32_t) ((1UL<<31) + i), 2) == i * 4 + 2);
}
for(unsigned i = 0; i < 3000; i++) {
+1 -1
View File
@@ -62,7 +62,7 @@ static void init_data(int data_size)
unsigned int j = (unsigned int)(data_size * ((double)x / UINT_MAX) / 4) * 271828183u;
string_printf(s, "%x", j);
array_string_push_back (v_str, s);
x = 1664525L * x + 1013904223L;
x = (uint32_t) (1664525L * x + 1013904223L);
}
string_clear(s);
}