summaryrefslogtreecommitdiff
path: root/lib/inttostr.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-10-31 09:42:37 +0100
committerJim Meyering <meyering@redhat.com>2009-10-31 09:42:37 +0100
commitc74c2411db5f3bf06848008c0d121a23fd31cf91 (patch)
tree40c8907b4d587854cb23b3bee52191c0b47c0aa3 /lib/inttostr.c
parent708e2420452bb7233e0153b0b92c4e7dc79e03e3 (diff)
downloadgnulib-c74c2411db5f3bf06848008c0d121a23fd31cf91.tar.gz
inttostr: aesthetics and improved (compile-time) safety
Define inttype_is_signed rather than inttype_is_unsigned, since the sole use is via "#if inttype_is_signed". * lib/imaxtostr.c (inttype_is_signed): Define this, rather than inttype_is_unsigned. * lib/offtostr.c (inttype_is_signed): Likewise. * lib/uinttostr.c (inttype_is_signed): Likewise. * lib/umaxtostr.c (inttype_is_signed): Likewise. * lib/inttostr.c (inttostr): Use verify to cross-check the inttype_is_signed value and the signedness of the actual type. * modules/inttostr (Depends-on): Add verify.
Diffstat (limited to 'lib/inttostr.c')
-rw-r--r--lib/inttostr.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/inttostr.c b/lib/inttostr.c
index 749aea7f6f..c7c0d736a6 100644
--- a/lib/inttostr.c
+++ b/lib/inttostr.c
@@ -20,6 +20,7 @@
#include <config.h>
#include "inttostr.h"
+#include "verify.h"
/* Convert I to a printable string in BUF, which must be at least
INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the
@@ -31,7 +32,8 @@ inttostr (inttype i, char *buf)
char *p = buf + INT_STRLEN_BOUND (inttype);
*p = 0;
-#ifndef inttype_is_unsigned
+ verify (TYPE_SIGNED (inttype) == inttype_is_signed);
+#if inttype_is_signed
if (i < 0)
{
do