[Build failure] tm struct tm_gmtoff field build error

Cary Coutant ccoutant@google.com
Tue Feb 17 21:48:00 GMT 2009


> Trying to compile a "--enable-targets=all" GDB
> on current cvs HEAD on cygwin,
> I found a new error in src/bfd:
> libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../purecvs/bfd -I. -I.
> -I../../p
> urecvs/bfd -I../../purecvs/bfd/../include -W -Wall -Wstrict-prototypes
> -Wmissing
> -prototypes -Werror -g -O2 -c ../../purecvs/bfd/vmsutil.c -o vmsutil.o
> ../../purecvs/bfd/vmsutil.c: In function `vms_file_stats_name':
> ../../purecvs/bfd/vmsutil.c:249: error: structure has no member named
> `tm_gmtoff'

Nick's follow-up patch on 1/21 still didn't fix the compilation
problems. The non-VMS code in this routine seems a bit confused:

  struct stat buff;
  struct tm *ts;

  if ((stat (filename, &buff)) != 0)
     return 1;

  if (cdt)
    {
      ts = localtime (&buff.st_mtime);
      *cdt = (long long) ((buff.st_mtim.tv_sec * VMS_GRANULARITY_FACTOR)
                          + (buff.st_mtim.tv_nsec / 100))
                         + VMS_EPOCH_OFFSET;
    }

The call to localtime was apparently there originally to get the
tm_gmtoff value -- after the 1/21 patch, the variable ts is not used.
On top of that, st_mtime is misspelled twice, and, when spelled
correctly, isn't a struct timeval, so it doesn't have tv_sec and
tv_nsec fields. This appears to be an attempt to get sub-second
granularity, but as far as I know, the stat() call does not provide
it.

I propose the following patch, but since I'm not sure what the code is
really meant to be doing, I don't consider it obvious.

-cary


        * vmsutil.c (vms_file_stats_name): Fix incorrect use of
st_mtime in struct stat.


Index: vmsutil.c
===================================================================
RCS file: /cvs/src/src/bfd/vmsutil.c,v
retrieving revision 1.2
diff -u -p -r1.2 vmsutil.c
--- vmsutil.c	21 Jan 2009 11:58:05 -0000	1.2
+++ vmsutil.c	17 Feb 2009 21:32:30 -0000
@@ -237,16 +237,13 @@ vms_file_stats_name (const char *filenam
   return 0;
 #else
   struct stat buff;
-  struct tm *ts;

   if ((stat (filename, &buff)) != 0)
      return 1;

   if (cdt)
     {
-      ts = localtime (&buff.st_mtime);
-      *cdt = (long long) ((buff.st_mtim.tv_sec * VMS_GRANULARITY_FACTOR)
-                          + (buff.st_mtim.tv_nsec / 100))
+      *cdt = (long long) (buff.st_mtime * VMS_GRANULARITY_FACTOR)
                          + VMS_EPOCH_OFFSET;
     }



More information about the Gdb mailing list