test/atom: use correct format specifier for size_t
authorRan Benita <ran@unusedvar.com>
Sat, 28 Dec 2019 12:11:27 +0000 (14:11 +0200)
committerRan Benita <ran@unusedvar.com>
Sat, 28 Dec 2019 12:13:52 +0000 (14:13 +0200)
From MSVC:

test\atom.c(98): note: consider using '%zu' in the format string
test\atom.c(98): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(100): note: consider using '%zu' in the format string
test\atom.c(100): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(114): note: consider using '%zu' in the format string
test\atom.c(114): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(128): note: consider using '%zu' in the format string
test\atom.c(128): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(130): note: consider using '%zu' in the format string
test\atom.c(130): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(137): note: consider using '%zu' in the format string
test\atom.c(137): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t'

Signed-off-by: Ran Benita <ran@unusedvar.com>
bench/key-proc.c
test/atom.c

index cee3dfa..1d29243 100644 (file)
@@ -75,7 +75,7 @@ main(void)
     xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
     xkb_context_set_log_verbosity(ctx, 0);
 
-    srand(time(NULL));
+    srand((unsigned) time(NULL));
 
     bench_start(&bench);
     bench_key_proc(state);
index 955b7da..a2f7541 100644 (file)
@@ -95,9 +95,9 @@ test_random_strings(void)
             if (arr[i].len != strlen(string) ||
                 strncmp(string, arr[i].string, arr[i].len) != 0) {
                 fprintf(stderr, "got a collision, but strings don't match!\n");
-                fprintf(stderr, "existing length %lu, string %s\n",
+                fprintf(stderr, "existing length %zu, string %s\n",
                         strlen(string), string);
-                fprintf(stderr, "new length %lu, string %.*s\n",
+                fprintf(stderr, "new length %zu, string %.*s\n",
                         arr[i].len, (int) arr[i].len, arr[i].string);
                 fprintf(stderr, "seed: %u\n", seed);
                 assert(false);
@@ -111,7 +111,7 @@ test_random_strings(void)
 
         arr[i].atom = atom_intern(table, arr[i].string, arr[i].len, true);
         if (arr[i].atom == XKB_ATOM_NONE) {
-            fprintf(stderr, "failed to intern! len: %lu, string: %.*s\n",
+            fprintf(stderr, "failed to intern! len: %zu, string: %.*s\n",
                     arr[i].len, (int) arr[i].len, arr[i].string);
             fprintf(stderr, "seed: %u\n", seed);
             assert(false);
@@ -125,16 +125,16 @@ test_random_strings(void)
         if (arr[i].len != strlen(string) ||
             strncmp(string, arr[i].string, arr[i].len) != 0) {
             fprintf(stderr, "looked-up string doesn't match!\n");
-            fprintf(stderr, "found length %lu, string %s\n",
+            fprintf(stderr, "found length %zu, string %s\n",
                     strlen(string), string);
-            fprintf(stderr, "expected length %lu, string %.*s\n",
+            fprintf(stderr, "expected length %zu, string %.*s\n",
                     arr[i].len, (int) arr[i].len, arr[i].string);
 
             /* Since this is random, we need to dump the failing data,
              * so we might have some chance to reproduce. */
             fprintf(stderr, "START dump of arr, N=%d\n", N);
             for (int j = 0; j < N; j++) {
-                fprintf(stderr, "%u\t\t%lu\t\t%.*s\n", arr[i].atom,
+                fprintf(stderr, "%u\t\t%zu\t\t%.*s\n", arr[i].atom,
                         arr[i].len, (int) arr[i].len, arr[i].string);
             }
             fprintf(stderr, "END\n");