diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2016-02-08 10:13:47 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2016-02-08 10:13:47 +0300 |
commit | c0ed77aa8ca564c7ee905dcf5dca032049a23967 (patch) | |
tree | bc1ae49ea5a345c18686c1832811a88b2aa8744e | |
parent | 2d98bd8d5fc56cf0c7e41838d42c1cc0786c2bd3 (diff) | |
download | libatomic_ops-c0ed77aa8ca564c7ee905dcf5dca032049a23967.tar.gz |
Eliminate 'signed-to-unsigned value extension' compiler warning in AO_malloc
* src/atomic_ops_malloc.c (msbs): Change type from int to unsigned
char.
* src/atomic_ops_malloc.c (msb): Change return type from int to
unsigned.
* src/atomic_ops_malloc.c (msb, AO_malloc): Change type of v, result,
log_sz local variables from int to unsigned.
-rw-r--r-- | src/atomic_ops_malloc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/atomic_ops_malloc.c b/src/atomic_ops_malloc.c index 60757cf..124c87c 100644 --- a/src/atomic_ops_malloc.c +++ b/src/atomic_ops_malloc.c @@ -224,16 +224,18 @@ static void add_chunk_as(void * chunk, unsigned log_sz) } } -static const int msbs[16] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4}; +static const unsigned char msbs[16] = { + 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 +}; /* Return the position of the most significant set bit in the */ /* argument. */ /* We follow the conventions of ffs(), i.e. the least */ /* significant bit is number one. */ -static int msb(size_t s) +static unsigned msb(size_t s) { - int result = 0; - int v; + unsigned result = 0; + unsigned v; if ((s & 0xff) != s) { /* The following is a tricky code ought to be equivalent to */ /* "(v = s >> 32) != 0" but suppresses warnings on 32-bit arch's. */ @@ -266,7 +268,7 @@ void * AO_malloc(size_t sz) { AO_t *result; - int log_sz; + unsigned log_sz; if (sz > CHUNK_SIZE) return AO_malloc_large(sz); |