-
Notifications
You must be signed in to change notification settings - Fork 582
Porting/timecheck.c: suppress build-time warnings #16775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From @jkeenanWhile looking at https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133688 and The patches are also in the smoke-me/jkeenan/timecheck-20181127 branch. Please review. Thank you very much. |
From @jkeenan0001-Use-more-plausible-argument-for-cd-in-example.patchFrom 7c22db276cbb3efde9868fc656adf1c0c956a63e Mon Sep 17 00:00:00 2001
From: James E Keenan <[email protected]>
Date: Tue, 27 Nov 2018 16:07:35 -0500
Subject: [PATCH 1/3] Use more plausible argument for 'cd' in example.
In our documentation we generally assume that the user is navigating
from the top-level of the core distribution. If so, then to compile a C
program found in Porting/ the user would simply 'cd Porting' rather than
'cd perl/Porting'.
---
Porting/README.y2038 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Porting/README.y2038 b/Porting/README.y2038
index 41087d5215..0e83775cf3 100644
--- a/Porting/README.y2038
+++ b/Porting/README.y2038
@@ -55,7 +55,7 @@ unix-like systems. For windows and VMS these values are hard-coded. You can
use timecheck.c in the Porting directory to check those values yourself,
using the same technique that is used in Configure based on bit-shifting:
- $ cd perl/Porting
+ $ cd Porting
$ cc -O -o timecheck timecheck.c
$ ./timecheck
======================
--
2.17.1
|
From @jkeenan0002-Eliminate-4-build-time-warnings-in-timecheck.c.patchFrom 3e20e816f40a8ac1b189c032a213614056eaa98e Mon Sep 17 00:00:00 2001
From: James E Keenan <[email protected]>
Date: Tue, 27 Nov 2018 16:12:45 -0500
Subject: [PATCH 2/3] Eliminate 4 build-time warnings in timecheck.c.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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
---
Porting/timecheck.c | 7 ++++---
1 file 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);
--
2.17.1
|
From @jkeenan0003-No-need-to-include-values.h.patchFrom 7caa8857e45c8b83983fb716160e5ac3b3aace34 Mon Sep 17 00:00:00 2001
From: James E Keenan <[email protected]>
Date: Tue, 27 Nov 2018 22:15:22 -0500
Subject: [PATCH 3/3] No need to include 'values.h'.
timecheck.c does not appear to use any thing from this file. Linux
documentation marks the interface as obsolete. It's not found, e.g., on
FreeBSD.
---
Porting/timecheck.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/Porting/timecheck.c b/Porting/timecheck.c
index e9e744121b..6ed70075be 100644
--- a/Porting/timecheck.c
+++ b/Porting/timecheck.c
@@ -6,7 +6,6 @@
#include <stdio.h>
#include <time.h>
#include <errno.h>
-#include <values.h>
#include <string.h>
int opt_v = 0;
--
2.17.1
|
From @jkeenanSummary of my perl5 (revision 5 version 29 subversion 6) configuration: Characteristics of this binary (from libperl): |
From @jkeenanOn Thu, 29 Nov 2018 18:07:01 GMT, jkeenan@pobox.com wrote:
After some review by, and discussion with Tux today on #p5p, the branch has been merged into blead. Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
@jkeenan - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.30.0, this and 160 other issues have been Perl 5.30.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#133701 (status was 'resolved')
Searchable as RT133701$
The text was updated successfully, but these errors were encountered: