Commit 826c281a authored by David Lawrence's avatar David Lawrence
Browse files

Solaris 5.6 gives this warning about a left shift to set the high bit:

	warning: integer overflow detected: op "<<"
unless the operand is unsigned/
parent f105c1cb
......@@ -18,6 +18,7 @@
#include <config.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h> /* Required for mkstemp on NetBSD. */
......@@ -84,10 +85,15 @@ isc_file_settime(const char *file, isc_time_t *time) {
* * isc_time_seconds is changed to be > 32 bits but long is 32 bits
* and isc_time_seconds has at least 33 significant bits.
*/
times[0].tv_sec = times[1].tv_sec =
(long)isc_time_seconds(time);
times[0].tv_sec = times[1].tv_sec = (long)isc_time_seconds(time);
if ((times[0].tv_sec & (1 << (sizeof(times[0].tv_sec) * 8 - 1))) != 0)
/*
* Solaris 5.6 gives this warning about the left shift:
* warning: integer overflow detected: op "<<"
* if the U(nsigned) qualifier is not on the 1.
*/
if ((times[0].tv_sec &
(1U << (sizeof(times[0].tv_sec) * CHAR_BIT - 1))) != 0)
return (ISC_R_RANGE);
/*
......
......@@ -342,8 +342,13 @@ isc_time_secondsastimet(isc_time_t *t, time_t *secondsp) {
* pretty much only true if time_t is a signed integer of the same
* size as the return value of isc_time_seconds.
*
* The use of a 64 bit integer takes advantage of C's conversion rules
* to either zero fill or sign extend the widened type.
* The use of the 64 bit integer ``i'' takes advantage of C's
* conversion rules to either zero fill or sign extend the widened
* type.
*
* Solaris 5.6 gives this warning about the left shift:
* warning: integer overflow detected: op "<<"
* if the U(nsigned) qualifier is not on the 1.
*/
seconds = (time_t)t->seconds;
......@@ -353,9 +358,10 @@ isc_time_secondsastimet(isc_time_t *t, time_t *secondsp) {
if (sizeof(time_t) == sizeof(isc_uint32_t) && /* Same size. */
(time_t)0.5 != 0.5 && /* Not a floating point type. */
(i = (time_t)-1) != 4294967295u && /* Is signed. */
(seconds & (1 << (sizeof(time_t) * 8 - 1))) != 0) { /* Negative. */
(seconds &
(1U << (sizeof(time_t) * CHAR_BIT - 1))) != 0) { /* Negative. */
/*
* This is here to shut up the IRIX compiler:
* This UNUSED() is here to shut up the IRIX compiler:
* variable "i" was set but never used
* when the value of i *was* used in the third test.
* (Let's hope the compiler got the actual test right.)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment