From: Ralph Corderoy Date: Thu, 17 Aug 2017 10:35:51 +0000 (+0100) Subject: cpnumber(): Cast desired width to size_t to silence gcc's warning. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/ac0bb0e1e19bedfd9d7105db0aad1cdfc5ef994f?ds=sidebyside cpnumber(): Cast desired width to size_t to silence gcc's warning. Add a comment on `wid = -wid' that it's OK because wid's value was originally a short so won't remain the same value. --- diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 50d7c4ca..075b7dd6 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -72,8 +72,8 @@ cpnumber(charstring_t dest, int num, int wid, char fill, size_t max) { if (wid == 0) return; if (wid < 0) - wid = -wid; - if (wid < (num >= 0 ? max : max-1)) { + wid = -wid; /* OK because wid originally a short. */ + if ((size_t)wid < (num >= 0 ? max : max-1)) { /* Build up the string representation of num in reverse. */ charstring_t rev = charstring_create (0); int i = num >= 0 ? num : -num;