Also improve the xrealloc error message in the same way that the xmalloc error message was recently improved. --- lib/xwrap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
-- Elliott Hughes - http://who/enh - http://jessies.org/~enh/ Android native code/tools questions? Mail me/drop by/add me as a reviewer.
From 12008794e12d97536259191ca062834ac20f2dee Mon Sep 17 00:00:00 2001 From: Elliott Hughes <[email protected]> Date: Mon, 4 Jan 2016 12:33:02 -0800 Subject: [PATCH] Use the correct printf specifier for size_t. Also improve the xrealloc error message in the same way that the xmalloc error message was recently improved. --- lib/xwrap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/xwrap.c b/lib/xwrap.c index 6d0c511..4d67aed 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -15,7 +15,7 @@ // still broken behavior. (And leaving the string unterminated is INSANE.) void xstrncpy(char *dest, char *src, size_t size) { - if (strlen(src)+1 > size) error_exit("'%s' > %ld bytes", src, (long)size); + if (strlen(src)+1 > size) error_exit("'%s' > %zu bytes", src, size); strcpy(dest, src); } @@ -24,7 +24,7 @@ void xstrncat(char *dest, char *src, size_t size) long len = strlen(src); if (len+strlen(dest)+1 > size) - error_exit("'%s%s' > %ld bytes", dest, src, (long)size); + error_exit("'%s%s' > %zu bytes", dest, src, size); strcpy(dest+len, src); } @@ -40,7 +40,7 @@ void xexit(void) void *xmalloc(size_t size) { void *ret = malloc(size); - if (!ret) error_exit("xmalloc(%ld)", (long)size); + if (!ret) error_exit("xmalloc(%zu)", size); return ret; } @@ -58,7 +58,7 @@ void *xzalloc(size_t size) void *xrealloc(void *ptr, size_t size) { ptr = realloc(ptr, size); - if (!ptr) error_exit("xrealloc"); + if (!ptr) error_exit("xrealloc(%zu)", size); return ptr; } -- 2.6.0.rc2.230.g3dd15c0
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
