mirror of
https://git.zx2c4.com/cgit
synced 2024-11-22 08:28:42 +00:00
ui-stats: if we're going to abuse void*, do it safely
This commit is contained in:
parent
85ec9f0211
commit
a8b9ef8c1c
17
ui-stats.c
17
ui-stats.c
@ -3,12 +3,6 @@
|
|||||||
#include "html.h"
|
#include "html.h"
|
||||||
#include "ui-shared.h"
|
#include "ui-shared.h"
|
||||||
|
|
||||||
#ifdef NO_C99_FORMAT
|
|
||||||
#define SZ_FMT "%u"
|
|
||||||
#else
|
|
||||||
#define SZ_FMT "%zu"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct authorstat {
|
struct authorstat {
|
||||||
long total;
|
long total;
|
||||||
struct string_list list;
|
struct string_list list;
|
||||||
@ -174,6 +168,7 @@ static void add_commit(struct string_list *authors, struct commit *commit,
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
struct tm *date;
|
struct tm *date;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
uintptr_t *counter;
|
||||||
|
|
||||||
info = cgit_parse_commit(commit);
|
info = cgit_parse_commit(commit);
|
||||||
tmp = xstrdup(info->author);
|
tmp = xstrdup(info->author);
|
||||||
@ -191,7 +186,9 @@ static void add_commit(struct string_list *authors, struct commit *commit,
|
|||||||
item = string_list_insert(items, tmp);
|
item = string_list_insert(items, tmp);
|
||||||
if (item->util)
|
if (item->util)
|
||||||
free(tmp);
|
free(tmp);
|
||||||
item->util++;
|
counter = (uintptr_t *)&item->util;
|
||||||
|
(*counter)++;
|
||||||
|
|
||||||
authorstat->total++;
|
authorstat->total++;
|
||||||
cgit_free_commitinfo(info);
|
cgit_free_commitinfo(info);
|
||||||
}
|
}
|
||||||
@ -286,7 +283,7 @@ static void print_combined_authorrow(struct string_list *authors, int from,
|
|||||||
items = &authorstat->list;
|
items = &authorstat->list;
|
||||||
date = string_list_lookup(items, tmp);
|
date = string_list_lookup(items, tmp);
|
||||||
if (date)
|
if (date)
|
||||||
subtotal += (size_t)date->util;
|
subtotal += (uintptr_t)date->util;
|
||||||
}
|
}
|
||||||
htmlf("<td class='%s'>%ld</td>", centerclass, subtotal);
|
htmlf("<td class='%s'>%ld</td>", centerclass, subtotal);
|
||||||
total += subtotal;
|
total += subtotal;
|
||||||
@ -340,8 +337,8 @@ static void print_authors(struct string_list *authors, int top,
|
|||||||
if (!date)
|
if (!date)
|
||||||
html("<td>0</td>");
|
html("<td>0</td>");
|
||||||
else {
|
else {
|
||||||
htmlf("<td>"SZ_FMT"</td>", (size_t)date->util);
|
htmlf("<td>%lu</td>", (uintptr_t)date->util);
|
||||||
total += (size_t)date->util;
|
total += (uintptr_t)date->util;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
htmlf("<td class='sum'>%ld</td></tr>", total);
|
htmlf("<td class='sum'>%ld</td></tr>", total);
|
||||||
|
Loading…
Reference in New Issue
Block a user