Fix format string warnings

C90 doesn't support z modifier in printf's, so cast values
to (unsigned long) which should be the same size as size_t
on both ILP32 and LP64.
This commit is contained in:
Mathew Mrosko 2009-11-16 21:49:19 +05:30 committed by Mukund Sivaraman
parent 2f05d8dd32
commit 238e3ffb34

View File

@ -38,8 +38,8 @@ void *debugging_calloc (size_t nmemb, size_t size, const char *file,
assert (size > 0); assert (size > 0);
ptr = calloc (nmemb, size); ptr = calloc (nmemb, size);
fprintf (stderr, "{calloc: %p:%zu x %zu} %s:%lu\n", ptr, nmemb, size, fprintf (stderr, "{calloc: %p:%lu x %lu} %s:%lu\n", ptr,
file, line); (unsigned long) nmemb, (unsigned long) size, file, line);
return ptr; return ptr;
} }
@ -50,7 +50,8 @@ void *debugging_malloc (size_t size, const char *file, unsigned long line)
assert (size > 0); assert (size > 0);
ptr = malloc (size); ptr = malloc (size);
fprintf (stderr, "{malloc: %p:%zu} %s:%lu\n", ptr, size, file, line); fprintf (stderr, "{malloc: %p:%lu} %s:%lu\n", ptr,
(unsigned long) size, file, line);
return ptr; return ptr;
} }
@ -62,8 +63,8 @@ void *debugging_realloc (void *ptr, size_t size, const char *file,
assert (size > 0); assert (size > 0);
newptr = realloc (ptr, size); newptr = realloc (ptr, size);
fprintf (stderr, "{realloc: %p -> %p:%zu} %s:%lu\n", ptr, newptr, size, fprintf (stderr, "{realloc: %p -> %p:%lu} %s:%lu\n", ptr, newptr,
file, line); (unsigned long) size, file, line);
return newptr; return newptr;
} }
@ -89,7 +90,8 @@ char *debugging_strdup (const char *s, const char *file, unsigned long line)
return NULL; return NULL;
memcpy (ptr, s, len); memcpy (ptr, s, len);
fprintf (stderr, "{strdup: %p:%zu} %s:%lu\n", ptr, len, file, line); fprintf (stderr, "{strdup: %p:%lu} %s:%lu\n", ptr,
(unsigned long) len, file, line);
return ptr; return ptr;
} }