From 44cc814bcafb470049f26de8e0a45ccc2c1a8c78 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Thu, 9 Feb 2017 08:00:31 -0800
Subject: [PATCH] Add lots of casts

---
 test/core/util/memory_counters.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/test/core/util/memory_counters.c b/test/core/util/memory_counters.c
index 0a782b3470..fd6770bd49 100644
--- a/test/core/util/memory_counters.c
+++ b/test/core/util/memory_counters.c
@@ -49,10 +49,14 @@ static void guard_free(void *vptr);
 static void *guard_malloc(size_t size) {
   size_t *ptr;
   if (!size) return NULL;
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_absolute, size);
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative, size);
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_absolute, 1);
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_relative, 1);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_absolute,
+                               (gpr_atm)size);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative,
+                               (gpr_atm)size);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_absolute,
+                               (gpr_atm)1);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_relative,
+                               (gpr_atm)1);
   ptr = g_old_allocs.malloc_fn(size + sizeof(size));
   *ptr++ = size;
   return ptr;
@@ -68,10 +72,14 @@ static void *guard_realloc(void *vptr, size_t size) {
     return NULL;
   }
   --ptr;
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_absolute, size);
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative, -*ptr);
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative, size);
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_absolute, 1);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_absolute,
+                               (gpr_atm)size);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative,
+                               -(gpr_atm)*ptr);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative,
+                               (gpr_atm)size);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_absolute,
+                               (gpr_atm)1);
   ptr = g_old_allocs.realloc_fn(ptr, size + sizeof(size));
   *ptr++ = size;
   return ptr;
@@ -81,8 +89,10 @@ static void guard_free(void *vptr) {
   size_t *ptr = vptr;
   if (!vptr) return;
   --ptr;
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative, -*ptr);
-  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_relative, -1);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_size_relative,
+                               -(gpr_atm)*ptr);
+  gpr_atm_no_barrier_fetch_add(&g_memory_counters.total_allocs_relative,
+                               -(gpr_atm)1);
   g_old_allocs.free_fn(ptr);
 }
 
-- 
GitLab