memlock: avoid type confusion in format string
authorSitsofe Wheeler <sitsofe@yahoo.com>
Mon, 31 Aug 2020 10:44:11 +0000 (11:44 +0100)
committerSitsofe Wheeler <sitsofe@yahoo.com>
Sat, 12 Sep 2020 10:54:19 +0000 (11:54 +0100)
Windows GCC has the followng grumble:

t/memlock.c: In function 'worker':
t/memlock.c:25:26: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'long long unsigned int'} [-Werror=format=]
   25 |    printf("loop%d: did %lu MiB\n", i+1, size/(1024UL*1024UL));
      |                        ~~^              ~~~~~~~~~~~~~~~~~~~~
      |                          |                  |
      |                          long unsigned int  size_t {aka long long unsigned int}
      |                        %llu

Fix it up by just using the original variable that was already in
megabytes.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
t/memlock.c

index 418dc3c48fd0c1b4cf8596564ee22f3f661fd92a..9f5a3ea8a731f5f4870e53e32a3baffe6f8e5189 100644 (file)
@@ -22,7 +22,7 @@ static void *worker(void *data)
                for (index = 0; index + 4096 < size; index += 4096)
                        memset(&buf[index+512], 0x89, 512);
                if (first) {
-                       printf("loop%d: did %lu MiB\n", i+1, size/(1024UL*1024UL));
+                       printf("loop%d: did %lu MiB\n", i+1, td->mib);
                        first = 0;
                }
        }