Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Cary Coutant <ccoutant@google.com>
To: Pierre Muller <muller@ics.u-strasbg.fr>
Cc: nickc@redhat.com, binutils@sourceware.org, gdb@sourceware.org
Subject: Re: [Build failure] tm struct tm_gmtoff field build error
Date: Tue, 17 Feb 2009 21:48:00 -0000	[thread overview]
Message-ID: <c17be2b30902171348o1865fe45nd74c35b54bb0bf93@mail.gmail.com> (raw)
In-Reply-To: <004301c97a33$0fa174d0$2ee45e70$@u-strasbg.fr>

> 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;
     }


  reply	other threads:[~2009-02-17 21:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-19 12:40 Pierre Muller
2009-02-17 21:48 ` Cary Coutant [this message]
2009-02-20  9:44   ` Nick Clifton
2009-02-20 19:05     ` Cary Coutant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c17be2b30902171348o1865fe45nd74c35b54bb0bf93@mail.gmail.com \
    --to=ccoutant@google.com \
    --cc=binutils@sourceware.org \
    --cc=gdb@sourceware.org \
    --cc=muller@ics.u-strasbg.fr \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox