From 17a407dc5184b2a0fe70677c911b0d6a1d10ffdd Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Tue, 29 Sep 2009 06:54:38 -0400 Subject: [PATCH] Use the correct conversion specifier for size_t. Reported by Jim Meyering. * src/Sbitset.h (SBITSET__INDEX__CONVERSION_SPEC): New, "zu" because Sbitset__Index is size_t. * src/Sbitset.c (Sbitset__fprint): Use it instead of %d. (cherry picked from commit 47eced3099712180364f4e01b839242027d9a9d8) --- ChangeLog | 8 ++++++++ src/Sbitset.c | 6 ++++-- src/Sbitset.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b233db9..12f3016f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-09-29 Joel E. Denny + + Use the correct conversion specifier for size_t. + Reported by Jim Meyering. + * src/Sbitset.h (SBITSET__INDEX__CONVERSION_SPEC): New, "zu" + because Sbitset__Index is size_t. + * src/Sbitset.c (Sbitset__fprint): Use it instead of %d. + 2009-09-27 Joel E. Denny tests: don't abuse AT_BISON_CHECK. diff --git a/src/Sbitset.c b/src/Sbitset.c index 0c1fedfc..af8600bd 100644 --- a/src/Sbitset.c +++ b/src/Sbitset.c @@ -65,14 +65,16 @@ Sbitset__fprint(Sbitset self, Sbitset__Index nbits, FILE *file) Sbitset__Index i; Sbitset itr; bool first = true; - fprintf (file, "nbits = %d, set = {", nbits); + fprintf (file, + "nbits = %" SBITSET__INDEX__CONVERSION_SPEC ", set = {", + nbits); SBITSET__FOR_EACH (self, nbits, itr, i) { if (first) first = false; else fprintf (file, ","); - fprintf (file, " %d", i); + fprintf (file, " %" SBITSET__INDEX__CONVERSION_SPEC, i); } fprintf (file, " }"); } diff --git a/src/Sbitset.h b/src/Sbitset.h index 4b4b7508..a0250404 100644 --- a/src/Sbitset.h +++ b/src/Sbitset.h @@ -22,6 +22,7 @@ typedef char *Sbitset; typedef size_t Sbitset__Index; +#define SBITSET__INDEX__CONVERSION_SPEC "zu" #define Sbitset__nbytes(NBITS) (((NBITS)+7)/8) #define Sbitset__byteAddress(SELF, INDEX) (((SELF) + (INDEX)/8)) -- 2.45.2