Skip to content

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

Closed
p5pRT opened this issue Nov 29, 2018 · 10 comments
Closed

Porting/timecheck.c: suppress build-time warnings #16775

p5pRT opened this issue Nov 29, 2018 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 29, 2018

Migrated from rt.perl.org#133701 (status was 'resolved')

Searchable as RT133701$

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2018

From @jkeenan

While looking at https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133688 and
poking around in the source code, I came across Porting/README.y2038 and
Porting/timecheck.c. I've never noticed either file before. I tried
out the instructions in README.y2038 for compiling and running
timecheck.c. I got build-time warnings which, in the patches attached,
I believe I have suppressed. I've also removed an 'include' that was
preventing timecheck.c from compiling on FreeBSD.

The patches are also in the smoke-me/jkeenan/timecheck-20181127 branch.

Please review.

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2018

From @jkeenan

0001-Use-more-plausible-argument-for-cd-in-example.patch
From 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

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2018

From @jkeenan

0002-Eliminate-4-build-time-warnings-in-timecheck.c.patch
From 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

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2018

From @jkeenan

0003-No-need-to-include-values.h.patch
From 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

@p5pRT
Copy link
Author

p5pRT commented Nov 29, 2018

From @jkeenan

Summary of my perl5 (revision 5 version 29 subversion 6) configuration​:
  Derived from​: fdfb42a
  Platform​:
  osname=linux
  osvers=4.15.0-39-generic
  archname=x86_64-linux
  uname='linux zareason 4.15.0-39-generic #42-ubuntu smp tue oct 23 15​:48​:01 utc 2018 x86_64 x86_64 x86_64 gnulinux '
  config_args='-des -Dusedevel'
  hint=recommended
  useposix=true
  d_sigaction=define
  useithreads=undef
  usemultiplicity=undef
  use64bitint=define
  use64bitall=define
  uselongdouble=undef
  usemymalloc=n
  default_inc_excludes_dot=define
  bincompat5005=undef
  Compiler​:
  cc='cc'
  ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
  optimize='-O2'
  cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
  ccversion=''
  gccversion='7.3.0'
  gccosandvers=''
  intsize=4
  longsize=8
  ptrsize=8
  doublesize=8
  byteorder=12345678
  doublekind=3
  d_longlong=define
  longlongsize=8
  d_longdbl=define
  longdblsize=16
  longdblkind=3
  ivtype='long'
  ivsize=8
  nvtype='double'
  nvsize=8
  Off_t='off_t'
  lseeksize=8
  alignbytes=8
  prototype=define
  Linker and Libraries​:
  ld='cc'
  ldflags =' -fstack-protector-strong -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /lib64 /usr/lib64
  libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
  perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
  libc=libc-2.27.so
  so=so
  useshrplib=false
  libperl=libperl.a
  gnulibc_version='2.27'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs
  dlext=so
  d_dlsymun=undef
  ccdlflags='-Wl,-E'
  cccdlflags='-fPIC'
  lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl)​:
  Compile-time options​:
  HAS_TIMES
  PERLIO_LAYERS
  PERL_COPY_ON_WRITE
  PERL_DONT_CREATE_GVSV
  PERL_MALLOC_WRAP
  PERL_OP_PARENT
  PERL_PRESERVE_IVUV
  PERL_USE_DEVEL
  USE_64_BIT_ALL
  USE_64_BIT_INT
  USE_LARGE_FILES
  USE_LOCALE
  USE_LOCALE_COLLATE
  USE_LOCALE_CTYPE
  USE_LOCALE_NUMERIC
  USE_LOCALE_TIME
  USE_PERLIO
  USE_PERL_ATOF
  Built under linux
  Compiled at Nov 28 2018 21​:59​:22
  %ENV​:
  PERL2DIR="/home/jkeenan/gitwork/perl2"
  PERLBREW_HOME="/home/jkeenan/.perlbrew"
  PERLBREW_MANPATH="/home/jkeenan/perl5/perlbrew/perls/perl-5.28.0/man"
  PERLBREW_PATH="/home/jkeenan/perl5/perlbrew/bin​:/home/jkeenan/perl5/perlbrew/perls/perl-5.28.0/bin"
  PERLBREW_PERL="perl-5.28.0"
  PERLBREW_ROOT="/home/jkeenan/perl5/perlbrew"
  PERLBREW_SHELLRC_VERSION="0.84"
  PERLBREW_VERSION="0.84"
  PERL_WORKDIR="/home/jkeenan/gitwork/perl"
  @​INC​:
  lib
  /usr/local/lib/perl5/site_perl/5.29.6/x86_64-linux
  /usr/local/lib/perl5/site_perl/5.29.6
  /usr/local/lib/perl5/5.29.6/x86_64-linux
  /usr/local/lib/perl5/5.29.6

@p5pRT
Copy link
Author

p5pRT commented Dec 7, 2018

From @jkeenan

On Thu, 29 Nov 2018 18​:07​:01 GMT, jkeenan@​pobox.com wrote​:

While looking at https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133688 and
poking around in the source code, I came across Porting/README.y2038 and
Porting/timecheck.c. I've never noticed either file before. I tried
out the instructions in README.y2038 for compiling and running
timecheck.c. I got build-time warnings which, in the patches attached,
I believe I have suppressed. I've also removed an 'include' that was
preventing timecheck.c from compiling on FreeBSD.

The patches are also in the smoke-me/jkeenan/timecheck-20181127 branch.

After some review by, and discussion with Tux today on #p5p, the branch has been merged into blead.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 7, 2018

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 7, 2018

@jkeenan - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 22, 2019

From @khwilliamson

Thank 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
resolved.

Perl 5.30.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.30.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented May 22, 2019

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant