Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From 7148adf34dae30345c2e4d9d437838a45ba6f6e8 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?utf8?q?Tim=20R=C3=BChsen?= <tim.ruehsen@gmx.de> |
| 3 | Date: Wed, 1 Feb 2017 11:06:39 +0100 |
| 4 | Subject: [PATCH] Fix -Wformat warnings |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6 | --- |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | Upstream-Status: Backport |
| 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | examples/example.c | 6 +++--- |
| 11 | examples/example3.c | 4 ++-- |
| 12 | examples/example4.c | 4 ++-- |
| 13 | examples/example5.c | 2 +- |
| 14 | src/idn.c | 2 +- |
| 15 | tests/tst_idna.c | 25 +++++++++++++------------ |
| 16 | tests/tst_idna2.c | 8 ++++---- |
| 17 | tests/tst_idna3.c | 8 ++++---- |
| 18 | tests/tst_nfkc.c | 8 ++++---- |
| 19 | tests/tst_pr29.c | 12 ++++++------ |
| 20 | tests/tst_punycode.c | 13 +++++++------ |
| 21 | tests/tst_strerror.c | 20 ++++++++++---------- |
| 22 | tests/tst_stringprep.c | 12 ++++++------ |
| 23 | tests/tst_tld.c | 20 ++++++++++---------- |
| 24 | tests/utils.c | 6 +++--- |
| 25 | 15 files changed, 76 insertions(+), 74 deletions(-) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 26 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 27 | diff --git a/examples/example.c b/examples/example.c |
| 28 | index 6e91783..24f64e0 100644 |
| 29 | --- a/examples/example.c |
| 30 | +++ b/examples/example.c |
| 31 | @@ -55,7 +55,7 @@ main (void) |
| 32 | |
| 33 | printf ("Before locale2utf8 (length %ld): ", (long int) strlen (buf)); |
| 34 | for (i = 0; i < strlen (buf); i++) |
| 35 | - printf ("%02x ", buf[i] & 0xFF); |
| 36 | + printf ("%02x ", (unsigned) buf[i] & 0xFF); |
| 37 | printf ("\n"); |
| 38 | |
| 39 | p = stringprep_locale_to_utf8 (buf); |
| 40 | @@ -69,7 +69,7 @@ main (void) |
| 41 | |
| 42 | printf ("Before stringprep (length %ld): ", (long int) strlen (buf)); |
| 43 | for (i = 0; i < strlen (buf); i++) |
| 44 | - printf ("%02x ", buf[i] & 0xFF); |
| 45 | + printf ("%02x ", (unsigned) buf[i] & 0xFF); |
| 46 | printf ("\n"); |
| 47 | |
| 48 | rc = stringprep (buf, BUFSIZ, 0, stringprep_nameprep); |
| 49 | @@ -79,7 +79,7 @@ main (void) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 50 | { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 51 | printf ("After stringprep (length %ld): ", (long int) strlen (buf)); |
| 52 | for (i = 0; i < strlen (buf); i++) |
| 53 | - printf ("%02x ", buf[i] & 0xFF); |
| 54 | + printf ("%02x ", (unsigned) buf[i] & 0xFF); |
| 55 | printf ("\n"); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 56 | } |
| 57 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 58 | diff --git a/examples/example3.c b/examples/example3.c |
| 59 | index fc11c1c..ffb9042 100644 |
| 60 | --- a/examples/example3.c |
| 61 | +++ b/examples/example3.c |
| 62 | @@ -56,7 +56,7 @@ main (void) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 63 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 64 | printf ("Read string (length %ld): ", (long int) strlen (buf)); |
| 65 | for (i = 0; i < strlen (buf); i++) |
| 66 | - printf ("%02x ", buf[i] & 0xFF); |
| 67 | + printf ("%02x ", (unsigned) buf[i] & 0xFF); |
| 68 | printf ("\n"); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 69 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 70 | rc = idna_to_ascii_lz (buf, &p, 0); |
| 71 | @@ -68,7 +68,7 @@ main (void) |
| 72 | |
| 73 | printf ("ACE label (length %ld): '%s'\n", (long int) strlen (p), p); |
| 74 | for (i = 0; i < strlen (p); i++) |
| 75 | - printf ("%02x ", p[i] & 0xFF); |
| 76 | + printf ("%02x ", (unsigned) p[i] & 0xFF); |
| 77 | printf ("\n"); |
| 78 | |
| 79 | free (p); |
| 80 | diff --git a/examples/example4.c b/examples/example4.c |
| 81 | index 1b319c9..a3315a1 100644 |
| 82 | --- a/examples/example4.c |
| 83 | +++ b/examples/example4.c |
| 84 | @@ -56,7 +56,7 @@ main (void) |
| 85 | |
| 86 | printf ("Read string (length %ld): ", (long int) strlen (buf)); |
| 87 | for (i = 0; i < strlen (buf); i++) |
| 88 | - printf ("%02x ", buf[i] & 0xFF); |
| 89 | + printf ("%02x ", (unsigned) buf[i] & 0xFF); |
| 90 | printf ("\n"); |
| 91 | |
| 92 | rc = idna_to_unicode_lzlz (buf, &p, 0); |
| 93 | @@ -68,7 +68,7 @@ main (void) |
| 94 | |
| 95 | printf ("ACE label (length %ld): '%s'\n", (long int) strlen (p), p); |
| 96 | for (i = 0; i < strlen (p); i++) |
| 97 | - printf ("%02x ", p[i] & 0xFF); |
| 98 | + printf ("%02x ", (unsigned) p[i] & 0xFF); |
| 99 | printf ("\n"); |
| 100 | |
| 101 | free (p); |
| 102 | diff --git a/examples/example5.c b/examples/example5.c |
| 103 | index df55798..29d40b9 100644 |
| 104 | --- a/examples/example5.c |
| 105 | +++ b/examples/example5.c |
| 106 | @@ -68,7 +68,7 @@ main (void) |
| 107 | |
| 108 | printf ("Read string (length %ld): ", (long int) strlen (buf)); |
| 109 | for (i = 0; i < strlen (buf); i++) |
| 110 | - printf ("%02x ", buf[i] & 0xFF); |
| 111 | + printf ("%02x ", (unsigned) buf[i] & 0xFF); |
| 112 | printf ("\n"); |
| 113 | |
| 114 | p = stringprep_locale_to_utf8 (buf); |
| 115 | diff --git a/src/idn.c b/src/idn.c |
| 116 | index be1c7d1..13eb3c9 100644 |
| 117 | --- a/src/idn.c |
| 118 | +++ b/src/idn.c |
| 119 | @@ -419,7 +419,7 @@ main (int argc, char *argv[]) |
| 120 | size_t i; |
| 121 | for (i = 0; p[i]; i++) |
| 122 | fprintf (stderr, "output[%lu] = U+%04x\n", |
| 123 | - (unsigned long) i, p[i]); |
| 124 | + (unsigned long) i, (unsigned) p[i]); |
| 125 | } |
| 126 | |
| 127 | fprintf (stdout, "%s\n", p); |
| 128 | diff --git a/tests/tst_idna.c b/tests/tst_idna.c |
| 129 | index 415764e..4ac046f 100644 |
| 130 | --- a/tests/tst_idna.c |
| 131 | +++ b/tests/tst_idna.c |
| 132 | @@ -220,13 +220,14 @@ doit (void) |
| 133 | char label[100]; |
| 134 | uint32_t *ucs4label = NULL; |
| 135 | uint32_t tmp[100]; |
| 136 | - size_t len, len2, i; |
| 137 | + size_t len, len2; |
| 138 | int rc; |
| 139 | + unsigned i; |
| 140 | |
| 141 | for (i = 0; i < sizeof (idna) / sizeof (idna[0]); i++) |
| 142 | { |
| 143 | if (debug) |
| 144 | - printf ("IDNA entry %ld: %s\n", i, idna[i].name); |
| 145 | + printf ("IDNA entry %u: %s\n", i, idna[i].name); |
| 146 | |
| 147 | if (debug) |
| 148 | { |
| 149 | @@ -237,7 +238,7 @@ doit (void) |
| 150 | rc = idna_to_ascii_4i (idna[i].in, idna[i].inlen, label, idna[i].flags); |
| 151 | if (rc != idna[i].toasciirc) |
| 152 | { |
| 153 | - fail ("IDNA entry %ld failed: %d\n", i, rc); |
| 154 | + fail ("IDNA entry %u failed: %d\n", i, rc); |
| 155 | if (debug) |
| 156 | printf ("FATAL\n"); |
| 157 | continue; |
| 158 | @@ -256,7 +257,7 @@ doit (void) |
| 159 | if (strlen (idna[i].out) != strlen (label) || |
| 160 | strcasecmp (idna[i].out, label) != 0) |
| 161 | { |
| 162 | - fail ("IDNA entry %ld failed\n", i); |
| 163 | + fail ("IDNA entry %u failed\n", i); |
| 164 | if (debug) |
| 165 | printf ("ERROR\n"); |
| 166 | } |
| 167 | @@ -273,8 +274,8 @@ doit (void) |
| 168 | |
| 169 | if (debug) |
| 170 | { |
| 171 | - printf ("in: %s (%ld==%ld)\n", idna[i].out, strlen (idna[i].out), |
| 172 | - len); |
| 173 | + printf ("in: %s (%d==%d)\n", idna[i].out, (int) strlen (idna[i].out), |
| 174 | + (int) len); |
| 175 | ucs4print (ucs4label, len); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 176 | } |
| 177 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 178 | @@ -282,20 +283,20 @@ doit (void) |
| 179 | rc = idna_to_unicode_44i (ucs4label, len, tmp, &len2, idna[i].flags); |
| 180 | if (debug) |
| 181 | { |
| 182 | - printf ("expected out (%ld):\n", |
| 183 | + printf ("expected out (%lu):\n", |
| 184 | rc == IDNA_SUCCESS ? idna[i].inlen : len); |
| 185 | if (rc == IDNA_SUCCESS) |
| 186 | ucs4print (idna[i].in, idna[i].inlen); |
| 187 | else |
| 188 | ucs4print (ucs4label, len); |
| 189 | |
| 190 | - printf ("computed out (%ld):\n", len2); |
| 191 | + printf ("computed out (%d):\n", (int) len2); |
| 192 | ucs4print (tmp, len2); |
| 193 | } |
| 194 | |
| 195 | if (rc != idna[i].tounicoderc) |
| 196 | { |
| 197 | - fail ("IDNA entry %ld failed: %d\n", i, rc); |
| 198 | + fail ("IDNA entry %u failed: %d\n", i, rc); |
| 199 | if (debug) |
| 200 | printf ("FATAL\n"); |
| 201 | continue; |
| 202 | @@ -309,11 +310,11 @@ doit (void) |
| 203 | if (debug) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 204 | { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 205 | if (rc == IDNA_SUCCESS) |
| 206 | - printf ("len=%ld len2=%ld\n", len2, idna[i].inlen); |
| 207 | + printf ("len=%d len2=%d\n", (int) len2, (int) idna[i].inlen); |
| 208 | else |
| 209 | - printf ("len=%ld len2=%ld\n", len, len2); |
| 210 | + printf ("len=%d len2=%d\n", (int) len, (int) len2); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 211 | } |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 212 | - fail ("IDNA entry %ld failed\n", i); |
| 213 | + fail ("IDNA entry %u failed\n", i); |
| 214 | if (debug) |
| 215 | printf ("ERROR\n"); |
| 216 | } |
| 217 | diff --git a/tests/tst_idna2.c b/tests/tst_idna2.c |
| 218 | index 65b3a4d..38932ca 100644 |
| 219 | --- a/tests/tst_idna2.c |
| 220 | +++ b/tests/tst_idna2.c |
| 221 | @@ -461,14 +461,14 @@ static const struct idna idna[] = { |
| 222 | void |
| 223 | doit (void) |
| 224 | { |
| 225 | - size_t i; |
| 226 | + unsigned i; |
| 227 | char *out; |
| 228 | int rc; |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 229 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 230 | for (i = 0; i < sizeof (idna) / sizeof (idna[0]); i++) |
| 231 | { |
| 232 | if (debug) |
| 233 | - printf ("IDNA2 entry %ld\n", i); |
| 234 | + printf ("IDNA2 entry %u\n", i); |
| 235 | |
| 236 | if (debug) |
| 237 | { |
| 238 | @@ -487,7 +487,7 @@ doit (void) |
| 239 | IDNA_USE_STD3_ASCII_RULES); |
| 240 | if (rc != IDNA_SUCCESS && strlen (idna[i].out) > 0) |
| 241 | { |
| 242 | - fail ("IDNA2 entry %ld failed: %d\n", i, rc); |
| 243 | + fail ("IDNA2 entry %u failed: %d\n", i, rc); |
| 244 | continue; |
| 245 | } |
| 246 | |
| 247 | @@ -504,7 +504,7 @@ doit (void) |
| 248 | if (strlen (idna[i].out) != strlen (out) || |
| 249 | strcasecmp (idna[i].out, out) != 0) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 250 | { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 251 | - fail ("IDNA2 entry %ld failed\n", i); |
| 252 | + fail ("IDNA2 entry %u failed\n", i); |
| 253 | if (debug) |
| 254 | printf ("ERROR\n"); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 255 | } |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 256 | diff --git a/tests/tst_idna3.c b/tests/tst_idna3.c |
| 257 | index a189378..f65628c 100644 |
| 258 | --- a/tests/tst_idna3.c |
| 259 | +++ b/tests/tst_idna3.c |
| 260 | @@ -59,13 +59,13 @@ doit (void) |
| 261 | { |
| 262 | int rc; |
| 263 | char *out = NULL; |
| 264 | - size_t i; |
| 265 | + unsigned i; |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 266 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 267 | for (i = 0; i < sizeof (idna) / sizeof (idna[0]); i++) |
| 268 | { |
| 269 | rc = idna_to_unicode_8z8z (idna[i].in, &out, 0); |
| 270 | if (rc != IDNA_SUCCESS) |
| 271 | - fail ("IDNA3[%ld] failed %d\n", i, rc); |
| 272 | + fail ("IDNA3[%u] failed %d\n", i, rc); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 273 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 274 | if (debug && rc == IDNA_SUCCESS) |
| 275 | { |
| 276 | @@ -75,9 +75,9 @@ doit (void) |
| 277 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 278 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 279 | if (strcmp (out, idna[i].out) != 0) |
| 280 | - fail ("IDNA3[%ld] failed\n", i); |
| 281 | + fail ("IDNA3[%u] failed\n", i); |
| 282 | else if (debug) |
| 283 | - printf ("IDNA3[%ld] success\n", i); |
| 284 | + printf ("IDNA3[%u] success\n", i); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 285 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 286 | if (out) |
| 287 | idn_free (out); |
| 288 | diff --git a/tests/tst_nfkc.c b/tests/tst_nfkc.c |
| 289 | index d150fec..f5af9c6 100644 |
| 290 | --- a/tests/tst_nfkc.c |
| 291 | +++ b/tests/tst_nfkc.c |
| 292 | @@ -68,18 +68,18 @@ void |
| 293 | doit (void) |
| 294 | { |
| 295 | char *out; |
| 296 | - size_t i; |
| 297 | + unsigned i; |
| 298 | |
| 299 | for (i = 0; i < sizeof (nfkc) / sizeof (nfkc[0]); i++) |
| 300 | { |
| 301 | if (debug) |
| 302 | - printf ("NFKC entry %ld\n", i); |
| 303 | + printf ("NFKC entry %u\n", i); |
| 304 | |
| 305 | out = stringprep_utf8_nfkc_normalize (nfkc[i].in, |
| 306 | (ssize_t) strlen (nfkc[i].in)); |
| 307 | if (out == NULL) |
| 308 | { |
| 309 | - fail ("NFKC entry %ld failed fatally\n", i); |
| 310 | + fail ("NFKC entry %u failed fatally\n", i); |
| 311 | continue; |
| 312 | } |
| 313 | |
| 314 | @@ -114,7 +114,7 @@ doit (void) |
| 315 | if (strlen (nfkc[i].out) != strlen (out) || |
| 316 | memcmp (nfkc[i].out, out, strlen (out)) != 0) |
| 317 | { |
| 318 | - fail ("NFKC entry %ld failed\n", i); |
| 319 | + fail ("NFKC entry %u failed\n", i); |
| 320 | if (debug) |
| 321 | printf ("ERROR\n"); |
| 322 | } |
| 323 | diff --git a/tests/tst_pr29.c b/tests/tst_pr29.c |
| 324 | index 3dc5466..11d0ede 100644 |
| 325 | --- a/tests/tst_pr29.c |
| 326 | +++ b/tests/tst_pr29.c |
| 327 | @@ -91,7 +91,7 @@ static const struct tv tv[] = { |
| 328 | void |
| 329 | doit (void) |
| 330 | { |
| 331 | - size_t i; |
| 332 | + unsigned i; |
| 333 | int rc; |
| 334 | |
| 335 | for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) |
| 336 | @@ -100,7 +100,7 @@ doit (void) |
| 337 | { |
| 338 | uint32_t *p, *q; |
| 339 | |
| 340 | - printf ("PR29 entry %ld: %s\n", i, tv[i].name); |
| 341 | + printf ("PR29 entry %u: %s\n", i, tv[i].name); |
| 342 | |
| 343 | printf ("in:\n"); |
| 344 | ucs4print (tv[i].in, tv[i].inlen); |
| 345 | @@ -120,7 +120,7 @@ doit (void) |
| 346 | rc = pr29_4 (tv[i].in, tv[i].inlen); |
| 347 | if (rc != tv[i].rc) |
| 348 | { |
| 349 | - fail ("PR29 entry %ld failed (expected %d): %d\n", i, tv[i].rc, rc); |
| 350 | + fail ("PR29 entry %u failed (expected %d): %d\n", i, tv[i].rc, rc); |
| 351 | if (debug) |
| 352 | printf ("FATAL\n"); |
| 353 | continue; |
| 354 | @@ -129,7 +129,7 @@ doit (void) |
| 355 | rc = pr29_4z (tv[i].in); |
| 356 | if (rc != tv[i].rc) |
| 357 | { |
| 358 | - fail ("PR29 entry %ld failed (expected %d): %d\n", i, tv[i].rc, rc); |
| 359 | + fail ("PR29 entry %u failed (expected %d): %d\n", i, tv[i].rc, rc); |
| 360 | if (debug) |
| 361 | printf ("FATAL\n"); |
| 362 | continue; |
| 363 | @@ -142,7 +142,7 @@ doit (void) |
| 364 | p = stringprep_ucs4_to_utf8 (tv[i].in, (ssize_t) tv[i].inlen, |
| 365 | &items_read, &items_written); |
| 366 | if (p == NULL) |
| 367 | - fail ("FAIL: stringprep_ucs4_to_utf8(tv[%ld]) == NULL\n", i); |
| 368 | + fail ("FAIL: stringprep_ucs4_to_utf8(tv[%u]) == NULL\n", i); |
| 369 | if (debug) |
| 370 | hexprint (p, strlen (p)); |
| 371 | |
| 372 | @@ -150,7 +150,7 @@ doit (void) |
| 373 | free (p); |
| 374 | if (rc != tv[i].rc) |
| 375 | { |
| 376 | - fail ("PR29 entry %ld failed (expected %d): %d\n", |
| 377 | + fail ("PR29 entry %u failed (expected %d): %d\n", |
| 378 | i, tv[i].rc, rc); |
| 379 | if (debug) |
| 380 | printf ("FATAL\n"); |
| 381 | diff --git a/tests/tst_punycode.c b/tests/tst_punycode.c |
| 382 | index 493b8a2..997744a 100644 |
| 383 | --- a/tests/tst_punycode.c |
| 384 | +++ b/tests/tst_punycode.c |
| 385 | @@ -173,7 +173,8 @@ doit (void) |
| 386 | char *p; |
| 387 | uint32_t *q; |
| 388 | int rc; |
| 389 | - size_t i, outlen; |
| 390 | + size_t outlen; |
| 391 | + unsigned i; |
| 392 | |
| 393 | p = malloc (sizeof (*p) * BUFSIZ); |
| 394 | if (p == NULL) |
| 395 | @@ -186,7 +187,7 @@ doit (void) |
| 396 | for (i = 0; i < sizeof (punycode) / sizeof (punycode[0]); i++) |
| 397 | { |
| 398 | if (debug) |
| 399 | - printf ("PUNYCODE entry %ld: %s\n", i, punycode[i].name); |
| 400 | + printf ("PUNYCODE entry %u: %s\n", i, punycode[i].name); |
| 401 | |
| 402 | if (debug) |
| 403 | { |
| 404 | @@ -199,7 +200,7 @@ doit (void) |
| 405 | NULL, &outlen, p); |
| 406 | if (rc != punycode[i].rc) |
| 407 | { |
| 408 | - fail ("punycode_encode() entry %ld failed: %d\n", i, rc); |
| 409 | + fail ("punycode_encode() entry %u failed: %d\n", i, rc); |
| 410 | if (debug) |
| 411 | printf ("FATAL\n"); |
| 412 | continue; |
| 413 | @@ -221,7 +222,7 @@ doit (void) |
| 414 | if (strlen (punycode[i].out) != strlen (p) || |
| 415 | memcmp (punycode[i].out, p, strlen (p)) != 0) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 416 | { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 417 | - fail ("punycode() entry %ld failed\n", i); |
| 418 | + fail ("punycode() entry %u failed\n", i); |
| 419 | if (debug) |
| 420 | printf ("ERROR\n"); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 421 | } |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 422 | @@ -241,7 +242,7 @@ doit (void) |
| 423 | &outlen, q, NULL); |
| 424 | if (rc != punycode[i].rc) |
| 425 | { |
| 426 | - fail ("punycode() entry %ld failed: %d\n", i, rc); |
| 427 | + fail ("punycode() entry %u failed: %d\n", i, rc); |
| 428 | if (debug) |
| 429 | printf ("FATAL\n"); |
| 430 | continue; |
| 431 | @@ -262,7 +263,7 @@ doit (void) |
| 432 | if (punycode[i].inlen != outlen || |
| 433 | memcmp (punycode[i].in, q, outlen) != 0) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 434 | { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 435 | - fail ("punycode_decode() entry %ld failed\n", i); |
| 436 | + fail ("punycode_decode() entry %u failed\n", i); |
| 437 | if (debug) |
| 438 | printf ("ERROR\n"); |
| 439 | } |
| 440 | diff --git a/tests/tst_strerror.c b/tests/tst_strerror.c |
| 441 | index 71fff59..730f5e4 100644 |
| 442 | --- a/tests/tst_strerror.c |
| 443 | +++ b/tests/tst_strerror.c |
| 444 | @@ -110,7 +110,7 @@ doit (void) |
| 445 | /* Iterate through all error codes. */ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 446 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 447 | { |
| 448 | - size_t i; |
| 449 | + unsigned i; |
| 450 | const char *last_p = NULL; |
| 451 | |
| 452 | for (i = 0;; i++) |
| 453 | @@ -126,13 +126,13 @@ doit (void) |
| 454 | break; |
| 455 | } |
| 456 | if (debug) |
| 457 | - printf ("idna %ld: %s\n", i, p); |
| 458 | + printf ("idna %u: %s\n", i, p); |
| 459 | last_p = p; |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | { |
| 464 | - size_t i; |
| 465 | + unsigned i; |
| 466 | const char *last_p = NULL; |
| 467 | |
| 468 | for (i = 0;; i++) |
| 469 | @@ -141,13 +141,13 @@ doit (void) |
| 470 | if (p == last_p) |
| 471 | break; |
| 472 | if (debug) |
| 473 | - printf ("pr29 %ld: %s\n", i, p); |
| 474 | + printf ("pr29 %u: %s\n", i, p); |
| 475 | last_p = p; |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | { |
| 480 | - size_t i; |
| 481 | + unsigned i; |
| 482 | const char *last_p = NULL; |
| 483 | |
| 484 | for (i = 0;; i++) |
| 485 | @@ -156,13 +156,13 @@ doit (void) |
| 486 | if (p == last_p) |
| 487 | break; |
| 488 | if (debug) |
| 489 | - printf ("punycode %ld: %s\n", i, p); |
| 490 | + printf ("punycode %u: %s\n", i, p); |
| 491 | last_p = p; |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | { |
| 496 | - size_t i; |
| 497 | + unsigned i; |
| 498 | const char *last_p = NULL; |
| 499 | |
| 500 | for (i = 0;; i++) |
| 501 | @@ -183,13 +183,13 @@ doit (void) |
| 502 | break; |
| 503 | } |
| 504 | if (debug) |
| 505 | - printf ("stringprep %ld: %s\n", i, p); |
| 506 | + printf ("stringprep %u: %s\n", i, p); |
| 507 | last_p = p; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | { |
| 512 | - size_t i; |
| 513 | + unsigned i; |
| 514 | const char *last_p = NULL; |
| 515 | |
| 516 | for (i = 0;; i++) |
| 517 | @@ -198,7 +198,7 @@ doit (void) |
| 518 | if (p == last_p) |
| 519 | break; |
| 520 | if (debug) |
| 521 | - printf ("tld %ld: %s\n", i, p); |
| 522 | + printf ("tld %u: %s\n", i, p); |
| 523 | last_p = p; |
| 524 | } |
| 525 | } |
| 526 | diff --git a/tests/tst_stringprep.c b/tests/tst_stringprep.c |
| 527 | index 149ce6f..7c9ab06 100644 |
| 528 | --- a/tests/tst_stringprep.c |
| 529 | +++ b/tests/tst_stringprep.c |
| 530 | @@ -205,7 +205,7 @@ doit (void) |
| 531 | { |
| 532 | char *p; |
| 533 | int rc; |
| 534 | - size_t i; |
| 535 | + unsigned i; |
| 536 | |
| 537 | if (!stringprep_check_version (STRINGPREP_VERSION)) |
| 538 | fail ("stringprep_check_version failed (header %s runtime %s)\n", |
| 539 | @@ -224,7 +224,7 @@ doit (void) |
| 540 | for (i = 0; i < sizeof (strprep) / sizeof (strprep[0]); i++) |
| 541 | { |
| 542 | if (debug) |
| 543 | - printf ("STRINGPREP entry %ld\n", i); |
| 544 | + printf ("STRINGPREP entry %u\n", i); |
| 545 | |
| 546 | if (debug) |
| 547 | { |
| 548 | @@ -247,12 +247,12 @@ doit (void) |
| 549 | continue; |
| 550 | else if (l == NULL) |
| 551 | { |
| 552 | - fail ("bad UTF-8 in entry %ld\n", i); |
| 553 | + fail ("bad UTF-8 in entry %u\n", i); |
| 554 | continue; |
| 555 | } |
| 556 | else if (strcmp (strprep[i].in, x) != 0) |
| 557 | { |
| 558 | - fail ("bad UTF-8 in entry %ld\n", i); |
| 559 | + fail ("bad UTF-8 in entry %u\n", i); |
| 560 | if (debug) |
| 561 | { |
| 562 | puts ("expected:"); |
| 563 | @@ -274,7 +274,7 @@ doit (void) |
| 564 | "Nameprep", strprep[i].flags); |
| 565 | if (rc != strprep[i].rc) |
| 566 | { |
| 567 | - fail ("stringprep() entry %ld failed: %d\n", i, rc); |
| 568 | + fail ("stringprep() entry %u failed: %d\n", i, rc); |
| 569 | if (debug) |
| 570 | printf ("FATAL\n"); |
| 571 | if (rc == STRINGPREP_OK) |
| 572 | @@ -302,7 +302,7 @@ doit (void) |
| 573 | if (strlen (strprep[i].out) != strlen (p) || |
| 574 | memcmp (strprep[i].out, p, strlen (p)) != 0) |
| 575 | { |
| 576 | - fail ("stringprep() entry %ld failed\n", i); |
| 577 | + fail ("stringprep() entry %ld failed\n", (long) i); |
| 578 | if (debug) |
| 579 | printf ("ERROR\n"); |
| 580 | } |
| 581 | diff --git a/tests/tst_tld.c b/tests/tst_tld.c |
| 582 | index 2f8e12e..d038c79 100644 |
| 583 | --- a/tests/tst_tld.c |
| 584 | +++ b/tests/tst_tld.c |
| 585 | @@ -80,7 +80,7 @@ const Tld_table * my_tld_tables[] = |
| 586 | void |
| 587 | doit (void) |
| 588 | { |
| 589 | - size_t i; |
| 590 | + unsigned i; |
| 591 | const Tld_table *tldtable; |
| 592 | char *out; |
| 593 | size_t errpos; |
| 594 | @@ -206,7 +206,7 @@ doit (void) |
| 595 | for (i = 0; i < sizeof (tld) / sizeof (tld[0]); i++) |
| 596 | { |
| 597 | if (debug) |
| 598 | - printf ("TLD entry %ld: %s\n", i, tld[i].name); |
| 599 | + printf ("TLD entry %u: %s\n", i, tld[i].name); |
| 600 | |
| 601 | if (debug) |
| 602 | { |
| 603 | @@ -217,7 +217,7 @@ doit (void) |
| 604 | tldtable = tld_default_table (tld[i].tld, NULL); |
| 605 | if (tldtable == NULL) |
| 606 | { |
| 607 | - fail ("TLD entry %ld tld_get_table (%s)\n", i, tld[i].tld); |
| 608 | + fail ("TLD entry %u tld_get_table (%s)\n", i, tld[i].tld); |
| 609 | if (debug) |
| 610 | printf ("FATAL\n"); |
| 611 | continue; |
| 612 | @@ -226,7 +226,7 @@ doit (void) |
| 613 | rc = tld_check_4t (tld[i].in, tld[i].inlen, &errpos, tldtable); |
| 614 | if (rc != tld[i].rc) |
| 615 | { |
| 616 | - fail ("TLD entry %ld failed: %d\n", i, rc); |
| 617 | + fail ("TLD entry %u failed: %d\n", i, rc); |
| 618 | if (debug) |
| 619 | printf ("FATAL\n"); |
| 620 | continue; |
| 621 | @@ -237,7 +237,7 @@ doit (void) |
| 622 | |
| 623 | if (rc != tld[i].rc) |
| 624 | { |
| 625 | - fail ("TLD entry %ld failed\n", i); |
| 626 | + fail ("TLD entry %u failed\n", i); |
| 627 | if (debug) |
| 628 | printf ("ERROR\n"); |
| 629 | } |
| 630 | @@ -245,12 +245,12 @@ doit (void) |
| 631 | { |
| 632 | if (debug) |
| 633 | printf ("returned errpos %ld expected errpos %ld\n", |
| 634 | - errpos, tld[i].errpos); |
| 635 | + (long) errpos, (long) tld[i].errpos); |
| 636 | |
| 637 | if (tld[i].errpos != errpos) |
| 638 | { |
| 639 | - fail ("TLD entry %ld failed because errpos %ld != %ld\n", i, |
| 640 | - tld[i].errpos, errpos); |
| 641 | + fail ("TLD entry %u failed because errpos %ld != %ld\n", i, |
| 642 | + (long) tld[i].errpos, (long) errpos); |
| 643 | if (debug) |
| 644 | printf ("ERROR\n"); |
| 645 | } |
| 646 | @@ -262,12 +262,12 @@ doit (void) |
| 647 | rc = tld_check_8z (tld[i].example, &errpos, NULL); |
| 648 | if (rc != tld[i].rc) |
| 649 | { |
| 650 | - fail ("TLD entry %ld failed\n", i); |
| 651 | + fail ("TLD entry %u failed\n", i); |
| 652 | if (debug) |
| 653 | printf ("ERROR\n"); |
| 654 | } |
| 655 | if (debug) |
| 656 | - printf ("TLD entry %ld tld_check_8z (%s)\n", i, tld[i].example); |
| 657 | + printf ("TLD entry %u tld_check_8z (%s)\n", i, tld[i].example); |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | diff --git a/tests/utils.c b/tests/utils.c |
| 662 | index 717ee01..5577dc3 100644 |
| 663 | --- a/tests/utils.c |
| 664 | +++ b/tests/utils.c |
| 665 | @@ -49,7 +49,7 @@ escapeprint (const char *str, size_t len) |
| 666 | { |
| 667 | size_t i; |
| 668 | |
| 669 | - printf (" (length %ld bytes):\n\t", len); |
| 670 | + printf (" (length %ld bytes):\n\t", (long) len); |
| 671 | for (i = 0; i < len; i++) |
| 672 | { |
| 673 | if (((str[i] & 0xFF) >= 'A' && (str[i] & 0xFF) <= 'Z') || |
| 674 | @@ -58,7 +58,7 @@ escapeprint (const char *str, size_t len) |
| 675 | || (str[i] & 0xFF) == ' ' || (str[i] & 0xFF) == '.') |
| 676 | printf ("%c", (str[i] & 0xFF)); |
| 677 | else |
| 678 | - printf ("\\x%02X", (str[i] & 0xFF)); |
| 679 | + printf ("\\x%02X", (unsigned) (str[i] & 0xFF)); |
| 680 | if ((i + 1) % 16 == 0 && (i + 1) < len) |
| 681 | printf ("'\n\t'"); |
| 682 | } |
| 683 | @@ -73,7 +73,7 @@ hexprint (const char *str, size_t len) |
| 684 | printf ("\t;; "); |
| 685 | for (i = 0; i < len; i++) |
| 686 | { |
| 687 | - printf ("%02x ", (str[i] & 0xFF)); |
| 688 | + printf ("%02x ", (unsigned) (str[i] & 0xFF)); |
| 689 | if ((i + 1) % 8 == 0) |
| 690 | printf (" "); |
| 691 | if ((i + 1) % 16 == 0 && i + 1 < len) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 692 | -- |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 693 | 1.9.1 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 694 | |