Fixed some compiler warnings about missing prototypes.
Fixed some other simple compiler warnings.
bk: 49709f66VY4tQgRNU4AaO2JZaiZ44A
+* [Bug 1118] Fixed sign extension for 32 bit time_t in caljulian() and prettydate().
+ Fixed some compiler warnings about missing prototypes.
+ Fixed some other simple compiler warnings.
(4.2.5p154) 2009/01/13 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 992] support interface event change on Linux from
Miroslav Lichvar.
* The buffer is removed from the free list. Make sure
* you put it back with freerecvbuf() or
*/
-extern struct recvbuf *get_free_recv_buffer (void);
+extern struct recvbuf *get_free_recv_buffer (void); /* signal safe - no malloc */
+extern struct recvbuf *get_free_recv_buffer_alloc (void); /* signal unsafe - may malloc */
/* Add a buffer to the full list
*/
*/
now = time(NULL);
tmplo = (u_int32)now;
+#if ( SIZEOF_TIME_T > 4 )
tmphi = (int32)(now >> 16 >> 16);
+#else
+ /*
+ * Get the correct sign extension in the high part.
+ * (now >> 32) may not work correctly on every 32 bit
+ * system, e.g. it yields garbage under Win32/VC6.
+ */
+ tmphi = (int32)(now >> 31);
+#endif
M_ADD(tmphi, tmplo, 0, ((1UL << 31)-1)); /* 32-bit max signed */
M_ADD(tmphi, tmplo, 0, JAN_1970);
*/
sclday = ntp_day * 7 + 217;
leaps = ((n1 == 3) && ((n4 != 24) || (n100 == 3))) ? 1 : 0;
- if (ntp_day >= JAN + FEB + leaps)
+ if (ntp_day >= (u_long)(JAN + FEB + leaps))
sclday += (2 - leaps) * 7;
++jt->year;
- jt->month = sclday / 214;
+ jt->month = (u_char)(sclday / 214);
jt->monthday = (u_char)((sclday % 214) / 7 + 1);
jt->yearday = (u_short)(1 + ntp_day);
}
int32 folds = 0;
time_t t = time(NULL);
u_int32 dwlo = (int32)t; /* might expand for SIZEOF_TIME_T < 4 */
+#if ( SIZEOF_TIME_T > 4 )
int32 dwhi = (int32)(t >> 16 >> 16);/* double shift: avoid warnings */
+#else
+ /*
+ * Get the correct sign extension in the high part.
+ * (now >> 32) may not work correctly on every 32 bit
+ * system, e.g. it yields garbage under Win32/VC6.
+ */
+ int32 dwhi = (int32)(t >> 31);
+#endif
/* Shift NTP to UN*X epoch, then unfold around currrent time. It's
* important to use a 32 bit max signed value -- LONG_MAX is 64 bit on
# endif /* Microsoft specific */
/* 't' should be a suitable value by now. Just go ahead. */
- while (!(tm = (*(local ? localtime : gmtime))(&t)))
+ while ( (tm = (*(local ? localtime : gmtime))(&t)) != 0)
/* seems there are some other pathological implementations of
** 'gmtime()' and 'localtime()' somewhere out there. No matter
** if we have 32-bit or 64-bit 'time_t', try to fix this by
#include "ntp_syscall.h"
#endif /* KERNEL_PLL */
+#ifdef OPENSSL
+#include <openssl/rand.h>
+#endif /* OPENSSL */
+
/*
* These routines provide support for the event timer. The timer is
* implemented by an interrupt routine which sets a flag once every
}
#ifdef OPENSSL
-
/*
* Garbage collect expired keys.
*/