]> granicus.if.org Git - libatomic_ops/commitdiff
Eliminate 'printf format specifies type void*' GCC pedantic warnings
authorIvan Maidanski <ivmai@mail.ru>
Wed, 7 Dec 2016 09:35:47 +0000 (12:35 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 6 Feb 2017 06:13:56 +0000 (09:13 +0300)
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).

src/atomic_ops_malloc.c

index 327c4ae4191471a054fb4cf66bbd0894abf643d0..631945cd5ceeb3613830f6978a6d151bcc7f0746 100644 (file)
@@ -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);