Re: new warnings in mktime.c

2005-06-23 Thread Paul Eggert
Jim Meyering [EMAIL PROTECTED] writes:

 Anyway, I installed this patch into coreutils.  Can you please try it
 with your GCC?  If it pacifies your GCC I'll propagate it into gnulib
 and glibc.

 It does.  Thanks!

OK, I installed it.  I also started the ball rolling on propagating
the changes into glibc; see
http://sources.redhat.com/bugzilla/show_bug.cgi?id=1033.


___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: new warnings in mktime.c

2005-06-22 Thread Paul Eggert
Jim Meyering [EMAIL PROTECTED] writes:

 With gcc-4.0 -O -Wall, I get these new warnings:

Odd; I don't get those warnings with gcc 4.0.0 -O -Wall:

$ gcc -DHAVE_CONFIG_H -I. -I.. -O -Wall -c mktime.c
$ gcc --version | sed 1q
gcc (GCC) 4.0.0

Anyway, I installed this patch into coreutils.  Can you please try it
with your GCC?  If it pacifies your GCC I'll propagate it into gnulib
and glibc.

2005-06-22  Paul Eggert  [EMAIL PROTECTED]

* mktime.c: Include string.h even if !DEBUG.  (From glibc.)
(ranged_convert): Don't save conversion in a temporary struct.
This causes a warning with GCC 4.0.0, and anyway in the typical
case it's not worth the extra 100 bytes or so of code.
(ranged_convert, __mktime_internal): When calling a function via a
pointer P, use P () rather than (*P) (), as we now assume C89 or better.

Index: mktime.c
===
RCS file: /fetish/cu/lib/mktime.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -p -u -r1.49 -r1.50
--- mktime.c14 May 2005 07:58:06 -  1.49
+++ mktime.c22 Jun 2005 19:07:41 -  1.50
@@ -1,5 +1,5 @@
 /* Convert a `struct tm' to a time_t value.
-   Copyright (C) 1993-1999, 2002, 2003, 2004, 2005 Free Software Foundation,
+   Copyright (C) 1993-1999, 2002-2004, 2005 Free Software Foundation, Inc.
Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert ([EMAIL PROTECTED]).
@@ -38,10 +38,11 @@
 
 #include limits.h
 
+#include string.h/* For the real memcpy prototype.  */
+
 #if DEBUG
 # include stdio.h
 # include stdlib.h
-# include string.h
 /* Make it work even if the system's libc has its own mktime routine.  */
 # define mktime my_mktime
 #endif /* DEBUG */
@@ -228,13 +229,12 @@ static struct tm *
 ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
time_t *t, struct tm *tp)
 {
-  struct tm *r;
+  struct tm *r = convert (t, tp);
 
-  if (! (r = (*convert) (t, tp))  *t)
+  if (!r  *t)
 {
   time_t bad = *t;
   time_t ok = 0;
-  struct tm tm;
 
   /* BAD is a known unconvertible time_t, and OK is a known good one.
 Use binary search to narrow the range between BAD and OK until
@@ -244,11 +244,9 @@ ranged_convert (struct tm *(*convert) (c
  time_t mid = *t = (bad  0
 ? bad + ((ok - bad)  1)
 : ok + ((bad - ok)  1));
- if ((r = (*convert) (t, tp)))
-   {
- tm = *r;
- ok = mid;
-   }
+ r = convert (t, tp);
+ if (r)
+   ok = mid;
  else
bad = mid;
}
@@ -258,8 +256,7 @@ ranged_convert (struct tm *(*convert) (c
  /* The last conversion attempt failed;
 revert to the most recent successful attempt.  */
  *t = ok;
- *tp = tm;
- r = tp;
+ r = convert (t, tp);
}
 }
 
@@ -488,7 +485,7 @@ __mktime_internal (struct tm *tp,
   t2 = t1 + sec_adjustment;
   if (((t1  t) != (sec_requested  0))
  | ((t2  t1) != (sec_adjustment  0))
- | ! (*convert) (t2, tm))
+ | ! convert (t2, tm))
return -1;
   t = t2;
 }


___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: new warnings in mktime.c

2005-06-22 Thread Jim Meyering
Paul Eggert [EMAIL PROTECTED] wrote:
 Jim Meyering [EMAIL PROTECTED] writes:

 With gcc-4.0 -O -Wall, I get these new warnings:

 Odd; I don't get those warnings with gcc 4.0.0 -O -Wall:

 $ gcc -DHAVE_CONFIG_H -I. -I.. -O -Wall -c mktime.c
 $ gcc --version | sed 1q
 gcc (GCC) 4.0.0

I'm using a slightly newer version:

  gcc-4.0 (GCC) 4.0.1 20050522 (prerelease) (Debian 4.0.0-9)

 Anyway, I installed this patch into coreutils.  Can you please try it
 with your GCC?  If it pacifies your GCC I'll propagate it into gnulib
 and glibc.

It does.  Thanks!


___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib