Mail Archives: djgpp-workers/2014/04/19/18:05:56
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 -