From 6ddd9d4fd8fadd9563d615a40dfaf26f9313c398 Mon Sep 17 00:00:00 2001 From: Martin Nilsson <nilsson@opera.com> Date: Wed, 5 Nov 2014 18:03:08 +0100 Subject: [PATCH] Address some warnings. --- src/block_alloc.h | 2 ++ src/encode.c | 8 +++++++- src/peep.c | 4 ++++ src/post_modules/Nettle/aead.cmod | 2 +- src/post_modules/Nettle/cipher.cmod | 8 ++++---- src/post_modules/Nettle/hogweed.cmod | 2 +- src/post_modules/Nettle/mac.cmod | 2 +- src/post_modules/Nettle/nettle.cmod | 2 +- src/stack_allocator.c | 2 ++ 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/block_alloc.h b/src/block_alloc.h index 16a52d1941..d37edc0bc1 100644 --- a/src/block_alloc.h +++ b/src/block_alloc.h @@ -62,7 +62,9 @@ static INLINE size_t ptr_hash_find_hashsize(size_t size) { size |= size >> 4; size |= size >> 8; size |= size >> 16; +#if SIZEOF_INT_TYPE > 4 size |= size >> 32; +#endif size++; } return size; diff --git a/src/encode.c b/src/encode.c index 1ae69c5111..b8506a9b60 100644 --- a/src/encode.c +++ b/src/encode.c @@ -2443,6 +2443,12 @@ static INT32 decode_portable_bytecode(struct decode_data *data, INT32 string_no) switch(bytecode->size_shift) { #define SIGNED_CHAR(X) X +#if SIZEOF_INT_TYPE > 4 +#define DO_HIGH(X) (X) +#else +#define DO_HIGH(X) 0 +#endif + /* The EMIT_BYTECODE2 macro will generate the warning * "comparison is always false due to limited range of data type" * if used on STR0. Thus, the need to have two macros here. @@ -2460,7 +2466,7 @@ static INT32 decode_portable_bytecode(struct decode_data *data, INT32 string_no) } else if (STR(bytecode)[e] == F_LINE) { \ current_line = \ ((unsigned INT32)STR(bytecode)[e+1]) | \ - ((INT_TYPE)STR(bytecode)[e+2])<<32; \ + DO_HIGH(((INT_TYPE)STR(bytecode)[e+2])<<32); \ } else if (!current_file) { \ decode_error(data, NULL, "Missing filename directive in " \ "byte code.\n"); \ diff --git a/src/peep.c b/src/peep.c index c5e06121b5..9f0d259b6c 100644 --- a/src/peep.c +++ b/src/peep.c @@ -253,7 +253,11 @@ INT32 assemble(int store_linenumbers) if (c[e].line != previous_line) { current_tripple[0] = F_LINE; current_tripple[1] = c[e].line; +#if SIZEOF_INT_TYPE > 4 current_tripple[2] = c[e].line>>32; +#else + current_tripple[2] = 0; +#endif current_tripple += 3; previous_line = c[e].line; } diff --git a/src/post_modules/Nettle/aead.cmod b/src/post_modules/Nettle/aead.cmod index c51ca4ecf6..3a480c13ed 100644 --- a/src/post_modules/Nettle/aead.cmod +++ b/src/post_modules/Nettle/aead.cmod @@ -436,7 +436,7 @@ PIKECLASS AEAD /* NB: Check iv length here so that we can use the * Nettle implementation straight in meta->set_iv. */ - if (iv->len != meta->iv_size || !meta->iv_size) { + if ((unsigned)iv->len != meta->iv_size || !meta->iv_size) { Pike_error("Invalid iv/nonce.\n"); } diff --git a/src/post_modules/Nettle/cipher.cmod b/src/post_modules/Nettle/cipher.cmod index 211da0cd36..97b8a27d81 100644 --- a/src/post_modules/Nettle/cipher.cmod +++ b/src/post_modules/Nettle/cipher.cmod @@ -1898,7 +1898,7 @@ PIKECLASS BlockCipher pike_nettle_crypt_func func = pike_crypt_func; void *ctx = THIS->object; struct pike_string *iv = THIS->iv; - int block_size = THIS->block_size; + unsigned block_size = (unsigned)THIS->block_size; NO_WIDE_STRING(data); @@ -1966,8 +1966,8 @@ PIKECLASS BlockCipher } } else { /* Decryption. */ - int trailer_len = data->len % block_size; - int blocked_len = data->len - trailer_len; + unsigned trailer_len = data->len % block_size; + unsigned blocked_len = data->len - trailer_len; if ((data->len >= CIPHER_THREADS_ALLOW_THRESHOLD) && (func != pike_crypt_func)) { /* Protect the iv from being freed by a different thread. */ @@ -2805,7 +2805,7 @@ PIKECLASS BlockCipher pike_nettle_crypt_func func = pike_crypt_func; void *ctx = THIS->object; struct pike_string *iv = THIS->iv; - int block_size = THIS->block_size; + unsigned block_size = (unsigned)THIS->block_size; uint8_t *src; uint8_t *dst; pike_nettle_size_t bytes; diff --git a/src/post_modules/Nettle/hogweed.cmod b/src/post_modules/Nettle/hogweed.cmod index 534728fca8..ad5d5ffd7f 100644 --- a/src/post_modules/Nettle/hogweed.cmod +++ b/src/post_modules/Nettle/hogweed.cmod @@ -32,7 +32,7 @@ static void random_func_wrapper(void *f, pike_nettle_size_t num, uint8_t *out) apply_svalue((struct svalue *)f, 1); if(TYPEOF(Pike_sp[-1])!=T_STRING) Pike_error("Random function did not return string value.\n"); - if(Pike_sp[-1].u.string->len != (unsigned int)num) + if((unsigned)Pike_sp[-1].u.string->len != (unsigned)num) Pike_error("Random function did not return correct number of bytes.\n"); memcpy(out, Pike_sp[-1].u.string->str, num); pop_stack(); diff --git a/src/post_modules/Nettle/mac.cmod b/src/post_modules/Nettle/mac.cmod index 1d8fa46fb4..cbfd294d18 100644 --- a/src/post_modules/Nettle/mac.cmod +++ b/src/post_modules/Nettle/mac.cmod @@ -245,7 +245,7 @@ PIKECLASS MAC /* NB: Check iv length here so that we can use the * Nettle implementation straight in meta->set_iv. */ - if ((iv->len > meta->iv_size) || !meta->iv_size) { + if (((unsigned)iv->len > meta->iv_size) || !meta->iv_size) { Pike_error("Invalid iv/nonce.\n"); } diff --git a/src/post_modules/Nettle/nettle.cmod b/src/post_modules/Nettle/nettle.cmod index d933ce37d1..765ddd182d 100644 --- a/src/post_modules/Nettle/nettle.cmod +++ b/src/post_modules/Nettle/nettle.cmod @@ -307,7 +307,7 @@ program_flags PROGRAM_CLEAR_STORAGE; */ PIKEFUN string(8bit) random_string(int len) { - unsigned stored = 0; + int stored = 0; struct string_builder s; if(len<0) Pike_error("Length has to be positive.\n"); diff --git a/src/stack_allocator.c b/src/stack_allocator.c index fbb9288413..5c69a9e3be 100644 --- a/src/stack_allocator.c +++ b/src/stack_allocator.c @@ -23,7 +23,9 @@ void stack_alloc_enlarge(struct stack_allocator * a, size_t len) { len |= len >> 4; len |= len >> 8; len |= len >> 16; +#if SIZEOF_INT_TYPE > 4 len |= len >> 32; +#endif len ++; } a->cur = alloc_chunk(len); -- GitLab