about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-12-31 10:14:29 +0000
committerEric Wong <e@80x24.org>2019-04-22 02:34:37 +0000
commit6a0cc29a3a1cfb4caee51e1bae1640375fee7d0e (patch)
treeef0c6b13984fe7d294529fbf90798940b86f1511
parent17920b7b72d1c907c740a7d1f79b90c66299043c (diff)
downloadcgit-6a0cc29a3a1cfb4caee51e1bae1640375fee7d0e.tar.gz
ui-stats.c: fix warning on 32-bit
gcc 6.3.0-18 on Debian stable emits the following warning,
despite uintptr_t and "unsigned long" having the same size:

> ../ui-stats.c: In function ‘print_authors’:
> ../ui-stats.c:340:18: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Wformat=]
>      htmlf("<td>%lu</td>", (uintptr_t)date->util);
>                   ^
-rw-r--r--ui-stats.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ui-stats.c b/ui-stats.c
index 7acd358..d7c4c97 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -337,8 +337,10 @@ static void print_authors(struct string_list *authors, int top,
                         if (!date)
                                 html("<td>0</td>");
                         else {
-                                htmlf("<td>%lu</td>", (uintptr_t)date->util);
-                                total += (uintptr_t)date->util;
+                                uintptr_t util = (uintptr_t)date->util;
+
+                                htmlf("<td>%"PRIuPTR"</td>", util);
+                                total += util;
                         }
                 }
                 htmlf("<td class='sum'>%ld</td></tr>", total);