Eliminate 64-bit compiler warnings in atomic_ops_malloc
authorIvan Maidanski <ivmai@mail.ru>
Sun, 7 Oct 2012 13:06:15 +0000 (17:06 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 7 Oct 2012 13:06:15 +0000 (17:06 +0400)
* src/atomic_ops_malloc.c (add_chunk_as): Cast shifted value to size_t
(the type of assigned variable, at least to eliminate compiler warning
for 64-bit targets).
* src/atomic_ops_malloc.c (AO_free): Cast (*base) to int (the type of
assigned variable) to eliminate MS VC compiler warning.

src/atomic_ops_malloc.c

index 40d80f3..6933880 100644 (file)
@@ -211,7 +211,7 @@ AO_stack_t AO_free_list[LOG_MAX_SIZE+1];
 static void add_chunk_as(void * chunk, unsigned log_sz)
 {
   size_t ofs, limit;
-  size_t sz = 1 << log_sz;
+  size_t sz = (size_t)1 << log_sz;
 
   assert (CHUNK_SIZE >= sz);
   limit = (size_t)CHUNK_SIZE - sz;
@@ -289,7 +289,7 @@ AO_free(void *p)
   int log_sz;
 
   if (0 == p) return;
-  log_sz = *(AO_t *)base;
+  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)));