diff options
author | James E Keenan <jkeenan@cpan.org> | 2018-11-27 16:12:45 -0500 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2018-12-07 23:09:23 +0000 |
commit | 252e731f408fa6f7a284ed879dee7a0d93156168 (patch) | |
tree | 47f59a66cf67832b0d384193094f257703b1fc40 /Porting/timecheck.c | |
parent | 90c09c683be291d22d2f06a3d926b59dc5677958 (diff) | |
download | perl-252e731f408fa6f7a284ed879dee7a0d93156168.tar.gz |
Eliminate 4 build-time warnings in timecheck.c.
This commit suppresses output like this:
[Porting] 758 $ cc -O -o timecheck timecheck.c
timecheck.c: In function ‘gm_check’:
timecheck.c:37:36: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘int’ [-Wformat=]
fprintf (stderr, "%3d:%s: %12ld-%02d-%02d %02d:%02d:%02d\n",
~~~~^
%12d
timecheck.c:39:3:
tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
~~~~~~~~~~~~~~~~~~~
timecheck.c: In function ‘lt_check’:
timecheck.c:89:36: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘int’ [-Wformat=]
fprintf (stderr, "%3d:%s: %12ld-%02d-%02d %02d:%02d:%02d\n",
~~~~^
%12d
timecheck.c:91:3:
tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
~~~~~~~~~~~~~~~~~~~
timecheck.c: In function ‘main’:
timecheck.c:130:21: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
if (argc > 1 && strcmp (argv[1], "-v") == 0) opt_v++;
^~~~~~
timecheck.c:139:32: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
printf ("Sizeof time_t = %ld\n", (i = sizeof (time_t)));
~~^ ~~~~~~~~~~~~~~~~~~~~~
%d
Diffstat (limited to 'Porting/timecheck.c')
-rw-r--r-- | Porting/timecheck.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Porting/timecheck.c b/Porting/timecheck.c index cf0303aaf4..e9e744121b 100644 --- a/Porting/timecheck.c +++ b/Porting/timecheck.c @@ -7,6 +7,7 @@ #include <time.h> #include <errno.h> #include <values.h> +#include <string.h> int opt_v = 0; int i; @@ -36,7 +37,7 @@ void gm_check (time_t t, int min_year, int max_year) if (opt_v) fprintf (stderr, "%3d:%s: %12ld-%02d-%02d %02d:%02d:%02d\n", i, hex (t), - tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, + (long)(tmp->tm_year) + 1900, tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); pt = t; } @@ -88,7 +89,7 @@ void lt_check (time_t t, int min_year, int max_year) if (opt_v) fprintf (stderr, "%3d:%s: %12ld-%02d-%02d %02d:%02d:%02d\n", i, hex (t), - tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, + (long)(tmp->tm_year) + 1900, tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); pt = t; } @@ -136,7 +137,7 @@ int main (int argc, char *argv[]) opt_v++; printf ("======================\n"); - printf ("Sizeof time_t = %ld\n", (i = sizeof (time_t))); + printf ("Sizeof time_t = %ld\n", (long)(i = sizeof (time_t))); printf ("gmtime () boundaries:\n"); gm_check (gm_max, 69, 0x7fffffff); gm_check (gm_min, -1900, 70); |