diff options
author | Tristan Gingold <gingold@adacore.com> | 2011-06-27 08:24:21 +0000 |
---|---|---|
committer | Tristan Gingold <gingold@adacore.com> | 2011-06-27 08:24:21 +0000 |
commit | 62a35308be34436a66993d20f36146cb4ebc500b (patch) | |
tree | 0ac418233b070673e89d87bc8db71a0cdf81a0bb /bfd | |
parent | bd8253459637af3935c3ee9bfdd512b151644bb3 (diff) | |
download | gdb-62a35308be34436a66993d20f36146cb4ebc500b.zip gdb-62a35308be34436a66993d20f36146cb4ebc500b.tar.gz gdb-62a35308be34436a66993d20f36146cb4ebc500b.tar.bz2 |
2011-06-27 Tristan Gingold <gingold@adacore.com>
* vms-misc.c (vms_time_to_time_t): Adjust overflow detection.
Add comment.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/vms-misc.c | 16 |
2 files changed, 17 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 58bf993..5028141 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2011-06-27 Tristan Gingold <gingold@adacore.com> + + * vms-misc.c (vms_time_to_time_t): Adjust overflow detection. + Add comment. + 2011-06-25 H.J. Lu <hongjiu.lu@intel.com> * elf64-x86-64.c (elf_backend_post_process_headers): Don't diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c index a2665b7..2ea2267 100644 --- a/bfd/vms-misc.c +++ b/bfd/vms-misc.c @@ -530,7 +530,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 +549,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 +566,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. */ |