delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2014/04/19/18:05:56

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Message-ID: <5352F0CD.7000001@gmx.de>
Date: Sat, 19 Apr 2014 23:55:25 +0200
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: [PATCH] fix library build for -Werror
References: <CAA2C=vBEXS=7Dp2yPwtv1noVt8FC3QGyczRyw8-uipyNscp9jg AT mail DOT gmail DOT com>
In-Reply-To: <CAA2C=vBEXS=7Dp2yPwtv1noVt8FC3QGyczRyw8-uipyNscp9jg@mail.gmail.com>
X-Provags-ID: V03:K0:ZQLJ1s760JFZ270Q+pbLFWyTxYIanHFgo3+TzLRfrB9wpEXzB3I
0fD0eiDO9U1HNLbJVsFavaEcUr7CW+ouX+IbOEYJMrdiuuLOjCXkGhMktWtlkb+7x+84Jmn
xZVyTf6d+rrbKkllL0VzGjHAo+DRl8GpVjKg6u5IVqwhBbKU8tsAxmmDJft0DYP0gqfnKnK
hgTmsvj6GnHLZ6whvkM5g==
Reply-To: djgpp-workers AT delorie DOT com

Am 13.04.2014 15:36, schrieb Ozkan Sezer:
> Current cvs fails building due to -Werror with gcc 3.3.6 and 3.4.6 :
>
> djasm.y:706.11-714.14: warning: unused value: $4
> ctime.c: In function `differ_by_repeat':
> ctime.c:286: warning: comparison is always false due to limited range
> of data type
> mkdtemp.c: In function `mkdtemp':
> mkdtemp.c:15: warning: 'rv' might be used uninitialized in this function
>
> The djasm warning doesn't stop the build, but the two others do.
> Here is a small patch that cures this: (also attached in case it gets
> mangled in the mail.)
>
> Index: libc/ansi/time/ctime.c
> ===================================================================
> RCS file: /cvs/djgpp/djgpp/src/libc/ansi/time/ctime.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 ctime.c
> --- djgpp/src/libc/ansi/time/ctime.c	17 Aug 2013 20:26:19 -0000	1.11
> +++ djgpp/src/libc/ansi/time/ctime.c	12 Apr 2014 07:11:50 -0000
> @@ -283,7 +283,7 @@ differ_by_repeat(const time_t t1, const
>   {
>     if (TYPE_INTEGRAL(time_t) && TYPE_BIT(time_t) - TYPE_SIGNED(time_t)
> < SECSPERREPEAT_BITS)
>       return 0;
> -  return t1 - t0 == SECSPERREPEAT;
> +  return (int_fast64_t)t1 - (int_fast64_t)t0 == SECSPERREPEAT;
>   }
>
>   static char *
> Index: libc/posix/stdlib/mkdtemp.c
> ===================================================================
> RCS file: /cvs/djgpp/djgpp/src/libc/posix/stdlib/mkdtemp.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 mkdtemp.c
> --- djgpp/src/libc/posix/stdlib/mkdtemp.c	10 Jan 2014 22:40:55 -0000	1.1
> +++ djgpp/src/libc/posix/stdlib/mkdtemp.c	12 Apr 2014 07:11:56 -0000
> @@ -12,8 +12,7 @@ mkdtemp(char *_template)
>   {
>     char tmp_name[FILENAME_MAX];
>     char real_path[FILENAME_MAX];
> -  int  rv;
> -
> +  int  rv = -1;
>
>     do {
>       strcpy(tmp_name, _template);
>
>
> For the ctime warning, googling shows the same solution as the one I
> did above, e.g.:  http://permalink.gmane.org/gmane.comp.time.tz/1928
>
> Apart from this, the distrib/mkdist script line #13 blindly assumes
> that the TMPDIR environment variable is set. If it is not, such as
> the case on at least one of my linux boxen, if fails miserably.
> Please cure it (I don't have a patch for it, I'm not a perl guy..)
>
> --
> O.S.

OFYI, I committed the patch below.

Regards,
Juan M. Guerrero




2014-01-26  Juan Manuel Guerrero  <juan DOT guerrero AT gmx DOT de>


     * djgpp/src/libc/ansi/time/ctime.c:  Fix warning: comparison is always false due to limited range of data type.
       From Ozkan Sezer <sezeroz AT gmail DOT com>

     * djgpp/src/libc/posix/stdlib/mkdtemp.c:  Fix warning: 'rv' might be used uninitialized in this function.
       From Ozkan Sezer <sezeroz AT gmail DOT com>

     * djgpp/distrib/mkdist:  Set a sane default for $tmpdir if TMPDIR is not set.





Logging in to :pserver:anonymous AT cvs DOT delorie DOT com:2401/cvs/djgpp
Index: djgpp/distrib/mkdist
===================================================================
RCS file: /cvs/djgpp/djgpp/distrib/mkdist,v
retrieving revision 1.5
diff -p -U 5 -r1.5 mkdist
--- djgpp/distrib/mkdist    20 Dec 2012 20:52:11 -0000    1.5
+++ djgpp/distrib/mkdist    19 Apr 2014 21:36:55 -0000
@@ -6,10 +6,24 @@ print "\nDon't forget to run rmtemps and
  $| = 1;

  $one = shift;

  $tmpdir = $ENV{'TMPDIR'};
+if ( !defined($tmpdir) ) {
+    if ( $^O eq 'dos' ) {
+        $tmpdir = $ENV{'TMP'};
+        if ( !defined($tmpdir) ) {
+            $tmpdir = $ENV{'TEMP'};
+            if ( !defined($tmpdir) ) {
+                mkdir("./tmp");
+                $tmpdir = "./tmp";
+            }
+        }
+    } else {
+        $tmpdir = "/tmp";
+    }
+}

  $cc = gcc;

  open(DIST, "mkdist.bat");
  chdir "..";
Index: djgpp/src/libc/ansi/time/ctime.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/time/ctime.c,v
retrieving revision 1.11
diff -p -U 5 -r1.11 ctime.c
--- djgpp/src/libc/ansi/time/ctime.c    17 Aug 2013 20:26:19 -0000    1.11
+++ djgpp/src/libc/ansi/time/ctime.c    19 Apr 2014 21:36:56 -0000
@@ -281,11 +281,11 @@ settzname(void)
  static int
  differ_by_repeat(const time_t t1, const time_t t0)
  {
    if (TYPE_INTEGRAL(time_t) && TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS)
      return 0;
-  return t1 - t0 == SECSPERREPEAT;
+  return (int_fast64_t)t1 - (int_fast64_t)t0 == SECSPERREPEAT;
  }

  static char *
  tzdir(void)
  {
Index: djgpp/src/libc/posix/stdlib/mkdtemp.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/stdlib/mkdtemp.c,v
retrieving revision 1.1
diff -p -U 5 -r1.1 mkdtemp.c
--- djgpp/src/libc/posix/stdlib/mkdtemp.c    10 Jan 2014 22:40:55 -0000    1.1
+++ djgpp/src/libc/posix/stdlib/mkdtemp.c    19 Apr 2014 21:36:56 -0000
@@ -10,12 +10,11 @@
  char *
  mkdtemp(char *_template)
  {
    char tmp_name[FILENAME_MAX];
    char real_path[FILENAME_MAX];
-  int  rv;
-
+  int  rv = -1;

    do {
      strcpy(tmp_name, _template);
      errno = 0;
    } while (mktemp(tmp_name) != NULL

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019