From: Dave Hart Date: Fri, 21 Oct 2011 19:10:02 +0000 (+0000) Subject: [Bug 2036] gcc 2.95.3 preprocessor can't nest #ifdef in macro args. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af52191ec3e401f02294dcd9e95dff286946729d;p=thirdparty%2Fntp.git [Bug 2036] gcc 2.95.3 preprocessor can't nest #ifdef in macro args. A number of compiler warnings eliminated. bk: 4ea1c38aDXOvWvJklhxgK4o6I5G1Pg --- diff --git a/ChangeLog b/ChangeLog index 142ef84e63..b5ffaa502c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +* [Bug 2036] gcc 2.95.3 preprocessor can't nest #ifdef in macro args. +* A number of compiler warnings eliminated. (4.2.7p226) 2011/10/21 Released by Harlan Stenn * [Bug 2035] ntpq -c mrulist sleeps 1 sec between queries, not 5 msec. * Documentation updates from Dave Mills. diff --git a/lib/isc/include/isc/file.h b/lib/isc/include/isc/file.h index c9457343e0..ffa633284b 100644 --- a/lib/isc/include/isc/file.h +++ b/lib/isc/include/isc/file.h @@ -30,10 +30,10 @@ ISC_LANG_BEGINDECLS isc_result_t -isc_file_settime(const char *file, isc_time_t *time); +isc_file_settime(const char *file, isc_time_t *itime); isc_result_t -isc_file_getmodtime(const char *file, isc_time_t *time); +isc_file_getmodtime(const char *file, isc_time_t *itime); /*!< * \brief Get the time of last modification of a file. * diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 8a3b95d9da..82abbed88b 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -70,7 +70,7 @@ * Use this in translation units that would otherwise be empty, to * suppress compiler warnings. */ -#define EMPTY_TRANSLATION_UNIT static void isc__empty(void) { isc__empty(); } +#define EMPTY_TRANSLATION_UNIT static char nonempty_translation_unit; /*% * We use macros instead of calling the routines directly because diff --git a/lib/isc/inet_ntop.c b/lib/isc/inet_ntop.c index 8b7931bab4..49e4776e25 100644 --- a/lib/isc/inet_ntop.c +++ b/lib/isc/inet_ntop.c @@ -46,6 +46,7 @@ static const char *inet_ntop4(const unsigned char *src, char *dst, static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size); #endif +const char *isc_net_ntop(int af, const void *src, char *dst, size_t size); /*! char * * isc_net_ntop(af, src, dst, size) @@ -92,7 +93,7 @@ inet_ntop4(const unsigned char *src, char *dst, size_t size) int len; len = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]); - if (len < 0 || len >= size) + if (len < 0 || (size_t)len >= size) { errno = ENOSPC; return (NULL); diff --git a/lib/isc/inet_pton.c b/lib/isc/inet_pton.c index cd5bb79b53..66b5de0bf4 100644 --- a/lib/isc/inet_pton.c +++ b/lib/isc/inet_pton.c @@ -43,6 +43,7 @@ static char rcsid[] = static int inet_pton4(const char *src, unsigned char *dst); static int inet_pton6(const char *src, unsigned char *dst); +int isc_net_pton(int af, const char *src, void *dst); /*% * convert from presentation format (which usually means ASCII printable) diff --git a/lib/isc/result.c b/lib/isc/result.c index 571358054e..9e2015f69b 100644 --- a/lib/isc/result.c +++ b/lib/isc/result.c @@ -112,14 +112,14 @@ static ISC_LIST(resulttable) tables; static isc_mutex_t lock; static isc_result_t -register_table(unsigned int base, unsigned int nresults, const char **text, +register_table(unsigned int base, unsigned int nresults, const char **txt, isc_msgcat_t *msgcat, int set) { resulttable *table; REQUIRE(base % ISC_RESULTCLASS_SIZE == 0); REQUIRE(nresults <= ISC_RESULTCLASS_SIZE); - REQUIRE(text != NULL); + REQUIRE(txt != NULL); /* * We use malloc() here because we we want to be able to use @@ -130,7 +130,7 @@ register_table(unsigned int base, unsigned int nresults, const char **text, return (ISC_R_NOMEMORY); table->base = base; table->last = base + nresults - 1; - table->text = text; + table->text = txt; table->msgcat = msgcat; table->set = set; ISC_LINK_INIT(table, link); @@ -170,14 +170,14 @@ initialize(void) { const char * isc_result_totext(isc_result_t result) { resulttable *table; - const char *text, *default_text; + const char *txt, *default_text; int index; initialize(); LOCK(&lock); - text = NULL; + txt = NULL; for (table = ISC_LIST_HEAD(tables); table != NULL; table = ISC_LIST_NEXT(table, link)) { @@ -189,25 +189,25 @@ isc_result_totext(isc_result_t result) { * instead of index because isc_msgcat_get() requires * the message number to be > 0. */ - text = isc_msgcat_get(table->msgcat, table->set, - index + 1, default_text); + txt = isc_msgcat_get(table->msgcat, table->set, + index + 1, default_text); break; } } - if (text == NULL) - text = isc_msgcat_get(isc_msgcat, ISC_RESULT_UNAVAILABLESET, - 1, "(result code text not available)"); + if (txt == NULL) + txt = isc_msgcat_get(isc_msgcat, ISC_RESULT_UNAVAILABLESET, + 1, "(result code text not available)"); UNLOCK(&lock); - return (text); + return (txt); } isc_result_t isc_result_register(unsigned int base, unsigned int nresults, - const char **text, isc_msgcat_t *msgcat, int set) + const char **txt, isc_msgcat_t *msgcat, int set) { initialize(); - return (register_table(base, nresults, text, msgcat, set)); + return (register_table(base, nresults, txt, msgcat, set)); } diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index 5a07bd0d4c..a127ea7dbf 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -98,12 +98,12 @@ file_stats(const char *file, struct stat *stats) { } isc_result_t -isc_file_getmodtime(const char *file, isc_time_t *time) { +isc_file_getmodtime(const char *file, isc_time_t *itime) { isc_result_t result; struct stat stats; REQUIRE(file != NULL); - REQUIRE(time != NULL); + REQUIRE(itime != NULL); result = file_stats(file, &stats); @@ -112,16 +112,16 @@ isc_file_getmodtime(const char *file, isc_time_t *time) { * XXXDCL some operating systems provide nanoseconds, too, * such as BSD/OS via st_mtimespec. */ - isc_time_set(time, stats.st_mtime, 0); + isc_time_set(itime, stats.st_mtime, 0); return (result); } isc_result_t -isc_file_settime(const char *file, isc_time_t *time) { +isc_file_settime(const char *file, isc_time_t *itime) { struct timeval times[2]; - REQUIRE(file != NULL && time != NULL); + REQUIRE(file != NULL && itime != NULL); /* * tv_sec is at least a 32 bit quantity on all platforms we're @@ -133,7 +133,7 @@ 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(itime); /* * Here is the real check for the high bit being set. @@ -149,7 +149,7 @@ isc_file_settime(const char *file, isc_time_t *time) { * we can at least cast to signed so the IRIX compiler shuts up. */ times[0].tv_usec = times[1].tv_usec = - (isc_int32_t)(isc_time_nanoseconds(time) / 1000); + (isc_int32_t)(isc_time_nanoseconds(itime) / 1000); if (utimes(file, times) < 0) return (isc__errno2result(errno)); diff --git a/libntp/msyslog.c b/libntp/msyslog.c index f1b67c958c..8ed9dc4e75 100644 --- a/libntp/msyslog.c +++ b/libntp/msyslog.c @@ -117,9 +117,13 @@ errno_to_str( # ifdef STRERROR_R_CHAR_P /* * For older GNU strerror_r, the return value either points to - * buf, or to static storage. We want the result always in buf + * buf, or to static storage. We want the result always in buf. + * On Debian Linux 6.03 with gcc 4.4, strerror_r() returns an + * int despite configure detecting STRERROR_R_CHAR_P. We are + * careful with the result, but need to cast to (char *) to + * silence gcc on Debian 6.03. */ - pstatic = strerror_r(err, buf, bufsiz); + pstatic = (char *)strerror_r(err, buf, bufsiz); # else pstatic = strerror(err); # endif diff --git a/libntp/snprintf.c b/libntp/snprintf.c index 9a72eb2de7..2b6a37473e 100644 --- a/libntp/snprintf.c +++ b/libntp/snprintf.c @@ -546,8 +546,6 @@ static UINTMAX_T cast(LDOUBLE); static UINTMAX_T myround(LDOUBLE); static LDOUBLE mypow10(int); -extern int errno; - int rpl_vsnprintf(char *str, size_t size, const char *format, va_list args); diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index ce9492d891..f5f78b9f0a 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -297,8 +297,10 @@ static int cmp_addr_distance(const sockaddr_u *, */ #if !defined(HAVE_IO_COMPLETION_PORT) static inline int read_network_packet (SOCKET, struct interface *, l_fp); -static inline int read_refclock_packet (SOCKET, struct refclockio *, l_fp); void ntpd_addremove_io_fd (int, int, int); +#ifdef REFCLOCK +static inline int read_refclock_packet (SOCKET, struct refclockio *, l_fp); +#endif #endif @@ -3078,6 +3080,8 @@ fdbits( return buffer; } + +#ifdef REFCLOCK /* * Routine to read the refclock packets for a specific interface * Return the number of bytes read. That way we know if we should @@ -3143,6 +3147,7 @@ read_refclock_packet( return buflen; } +#endif /* REFCLOCK */ #ifdef HAVE_TIMESTAMP diff --git a/ntpd/refclock_nmea.c b/ntpd/refclock_nmea.c index ac7cfa721f..240de5a6f1 100644 --- a/ntpd/refclock_nmea.c +++ b/ntpd/refclock_nmea.c @@ -1011,7 +1011,9 @@ nmea_poll( ) { struct refclockproc * const pp = peer->procptr; +#ifdef HAVE_PPSAPI nmea_unit * const up = (nmea_unit *)pp->unitptr; +#endif /* * Process median filter samples. If none received, declare a diff --git a/ntpd/refclock_parse.c b/ntpd/refclock_parse.c index 046a1d62b5..8f20ab7210 100644 --- a/ntpd/refclock_parse.c +++ b/ntpd/refclock_parse.c @@ -2940,12 +2940,11 @@ parse_start( #ifndef O_NOCTTY #define O_NOCTTY 0 #endif - - fd232 = tty_open(parsedev, O_RDWR | O_NOCTTY -#ifdef O_NONBLOCK - | O_NONBLOCK +#ifndef O_NONBLOCK +#define O_NONBLOCK 0 #endif - , 0777); + + fd232 = tty_open(parsedev, O_RDWR | O_NOCTTY | O_NONBLOCK, 0777); if (fd232 == -1) { @@ -3067,11 +3066,7 @@ parse_start( * if the PARSEPPSDEVICE can be opened that will be used * for PPS else PARSEDEVICE will be used */ - parse->ppsfd = tty_open(parseppsdev, O_RDWR | O_NOCTTY -#ifdef O_NONBLOCK - | O_NONBLOCK -#endif - , 0777); + parse->ppsfd = tty_open(parseppsdev, O_RDWR | O_NOCTTY | O_NONBLOCK, 0777); if (parse->ppsfd == -1) { @@ -3639,7 +3634,7 @@ parse_event( if (parse->parse_type->cl_event) parse->parse_type->cl_event(parse, event); - + if (event == CEVNT_NOMINAL) { NLOG(NLOG_CLOCKSTATUS) @@ -3663,6 +3658,9 @@ parse_process( l_fp off, rectime, reftime; double fudge; + /* silence warning: 'off.Ul_i.Xl_i' may be used uninitialized in this function */ + ZERO(off); + /* * check for changes in conversion status * (only one for each new status !) diff --git a/ntpd/refclock_wwvb.c b/ntpd/refclock_wwvb.c index 8472f86971..75897fcc55 100644 --- a/ntpd/refclock_wwvb.c +++ b/ntpd/refclock_wwvb.c @@ -455,7 +455,9 @@ wwvb_timer( register struct wwvbunit *up; struct refclockproc *pp; char pollchar; /* character sent to clock */ +#ifdef DEBUG l_fp now; +#endif /* * Time to poll the clock. The Spectracom clock responds to a