summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-12-07 12:35:47 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-12-07 12:35:47 +0300
commit83363ad9a83a6b1553cda9f6e4c95d6cfeccd31a (patch)
tree93408959c02cc426361c3ab70e833930415a2575
parent8fc1a2ffc4bb47bf11e61864768810a9561c770b (diff)
downloadlibatomic_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.c8
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);