diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2016-12-07 12:35:47 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2016-12-07 12:35:47 +0300 |
commit | 83363ad9a83a6b1553cda9f6e4c95d6cfeccd31a (patch) | |
tree | 93408959c02cc426361c3ab70e833930415a2575 | |
parent | 8fc1a2ffc4bb47bf11e61864768810a9561c770b (diff) | |
download | libatomic_ops-83363ad9a83a6b1553cda9f6e4c95d6cfeccd31a.tar.gz |
Eliminate 'printf format specifies type void*' GCC pedantic warnings
This commit also eliminates 'cast from pointer to integer' compiler
warnings and '32-bit value shift followed by expansion to 64-bit'
static analysis tool warning.
* src/atomic_ops_malloc.c [AO_TRACE_MALLOC] (AO_malloc, AO_free):
Use %p (instead of %x) format specifier to print pthread_self() value
(and cast pthread_self() to void*).
* src/atomic_ops_malloc.c [AO_TRACE_MALLOC] (AO_malloc): Cast result+1
to void* (to match %p printf format specifier).
* src/atomic_ops_malloc.c [AO_TRACE_MALLOC] (AO_free): Use "UL" suffix
for 1 and remove the cast to unsigned long (instead of performing left
shift of an integer value and extending the result to unsigned long).
-rw-r--r-- | src/atomic_ops_malloc.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/atomic_ops_malloc.c b/src/atomic_ops_malloc.c index d83e43d..aae21d0 100644 --- a/src/atomic_ops_malloc.c +++ b/src/atomic_ops_malloc.c @@ -297,8 +297,8 @@ AO_malloc(size_t sz) } *result = log_sz; # ifdef AO_TRACE_MALLOC - fprintf(stderr, "%x: AO_malloc(%lu) = %p\n", - (int)pthread_self(), (unsigned long)sz, result+1); + fprintf(stderr, "%p: AO_malloc(%lu) = %p\n", + (void *)pthread_self(), (unsigned long)sz, (void *)(result + 1)); # endif return result + 1; } @@ -314,8 +314,8 @@ AO_free(void *p) base = (AO_t *)p - 1; log_sz = (int)(*base); # ifdef AO_TRACE_MALLOC - fprintf(stderr, "%x: AO_free(%p sz:%lu)\n", (int)pthread_self(), p, - (unsigned long)(log_sz > LOG_MAX_SIZE? log_sz : (1 << log_sz))); + fprintf(stderr, "%p: AO_free(%p sz:%lu)\n", (void *)pthread_self(), p, + log_sz > LOG_MAX_SIZE ? (unsigned)log_sz : 1UL << log_sz); # endif if (log_sz > LOG_MAX_SIZE) AO_free_large(p); |