From: Ivan Maidanski Date: Wed, 7 Dec 2016 09:35:47 +0000 (+0300) Subject: Eliminate 'printf format specifies type void*' GCC pedantic warnings X-Git-Tag: v7.4.6~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc0f5be0c1f06d282568d27ddc8be27301ab7f6a;p=libatomic_ops 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). --- diff --git a/src/atomic_ops_malloc.c b/src/atomic_ops_malloc.c index 327c4ae..631945c 100644 --- a/src/atomic_ops_malloc.c +++ b/src/atomic_ops_malloc.c @@ -295,8 +295,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; } @@ -310,8 +310,8 @@ AO_free(void *p) if (0 == p) return; log_sz = (int)(*(AO_t *)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);