Tidy code setting PT_GNU_RELRO p_flags
[deliverable/binutils-gdb.git] / bfd / vms-misc.c
index a2665b7e4f938986a45aeb3e5394278ff8b5d23a..8571e2f99799966945296b1147b8c914e6745633 100644 (file)
@@ -1,7 +1,6 @@
 /* vms-misc.c -- BFD back-end for VMS/VAX (openVMS/VAX) and
    EVAX (openVMS/Alpha) files.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+   Copyright (C) 1996-2015 Free Software Foundation, Inc.
 
    Miscellaneous functions.
 
@@ -530,7 +529,10 @@ vms_get_module_name (const char *filename, bfd_boolean upcase)
    -  100ns granularity
    -  epoch is Nov 17, 1858.
    Here has the constants and the routines used to convert VMS from/to UNIX time.
-   The conversion routines don't assume 64 bits arithmetic.  */
+   The conversion routines don't assume 64 bits arithmetic.
+
+   Here we assume that the definition of time_t is the UNIX one, ie integer
+   type, expressing seconds since the epoch.  */
 
 /* UNIX time granularity for VMS, ie 1s / 100ns.  */
 #define VMS_TIME_FACTOR 10000000
@@ -546,6 +548,7 @@ vms_time_to_time_t (unsigned int hi, unsigned int lo)
   unsigned int tmp;
   unsigned int rlo;
   int i;
+  time_t res;
 
   /* First convert to seconds.  */
   tmp = hi % VMS_TIME_FACTOR;
@@ -562,14 +565,18 @@ vms_time_to_time_t (unsigned int hi, unsigned int lo)
   lo = rlo;
 
   /* Return 0 in case of overflow.  */
-  if (lo > VMS_TIME_OFFSET && hi > 1)
+  if (hi > 1
+      || (hi == 1 && lo >= VMS_TIME_OFFSET))
     return 0;
 
   /* Return 0 in case of underflow.  */
-  if (lo < VMS_TIME_OFFSET)
+  if (hi == 0 && lo < VMS_TIME_OFFSET)
     return 0;
 
-  return lo - VMS_TIME_OFFSET;
+  res = lo - VMS_TIME_OFFSET;
+  if (res <= 0)
+    return 0;
+  return res;
 }
 
 /* Convert a time_t to a VMS time.  */
This page took 0.0248 seconds and 4 git commands to generate.