Download raw body.
gotwebd: another format specifier mismatch
On Sun, Jul 17, 2022 at 04:32:20PM +0200, Christian Weisgerber wrote:
> gotweb_get_time_str() has a variable time_t diff_time that is fed
> to a printf() function seven times. We could cast it to long long
> each time, but that is ugly. Maybe change the variable type instead?
>
> As seen on FreeBSD:
>
> gotweb.c:2788:8: warning: format specifies type 'long long' but the argument has
> type 'long' [-Wformat]
> (diff_time / 60 / 60 / 24 / 365), years) == -1)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> gotweb.c:2792:8: warning: format specifies type 'long long' but the argument has
> type 'long' [-Wformat]
> (diff_time / 60 / 60 / 24 / (365 / 12)),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> gotweb.c:2797:8: warning: format specifies type 'long long' but the argument has
> type 'long' [-Wformat]
> (diff_time / 60 / 60 / 24 / 7), weeks) == -1)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> gotweb.c:2801:8: warning: format specifies type 'long long' but the argument has
> type 'long' [-Wformat]
> (diff_time / 60 / 60 / 24), days) == -1)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> gotweb.c:2805:8: warning: format specifies type 'long long' but the argument has
> type 'long' [-Wformat]
> (diff_time / 60 / 60), hours) == -1)
> ^~~~~~~~~~~~~~~~~~~~~
> gotweb.c:2808:38: warning: format specifies type 'long long' but the argument ha
> s type 'long' [-Wformat]
> if (asprintf(repo_age, "%lld %s", (diff_time / 60),
> ~~~~ ^~~~~~~~~~~~~~~~
> %ld
> gotweb.c:2812:38: warning: format specifies type 'long long' but the argument has type 'time_t' (aka 'long') [-Wformat]
> if (asprintf(repo_age, "%lld %s", diff_time,
> ~~~~ ^~~~~~~~~
> %ld
> 7 warnings generated.
>
>
> diff /home/naddy/got
> commit - d6267a62d388995cbc79bb58ce9db7946fda0554
> path + /home/naddy/got
> blob - 1f77113aefd24cce886b89debd8d60dc71eca3fd
> file + gotwebd/gotweb.c
> --- gotwebd/gotweb.c
> +++ gotwebd/gotweb.c
> @@ -2768,7 +2768,7 @@ const struct got_error *
> gotweb_get_time_str(char **repo_age, time_t committer_time, int ref_tm)
> {
> struct tm tm;
> - time_t diff_time;
> + long long diff_time;
> const char *years = "years ago", *months = "months ago";
> const char *weeks = "weeks ago", *days = "days ago";
> const char *hours = "hours ago", *minutes = "minutes ago";
>
> --
> Christian "naddy" Weisgerber naddy@mips.inka.de
>
ok
--
Tracey Emery
gotwebd: another format specifier mismatch