]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2036] gcc 2.95.3 preprocessor can't nest #ifdef in macro args.
authorDave Hart <hart@ntp.org>
Fri, 21 Oct 2011 19:10:02 +0000 (19:10 +0000)
committerDave Hart <hart@ntp.org>
Fri, 21 Oct 2011 19:10:02 +0000 (19:10 +0000)
A number of compiler warnings eliminated.

bk: 4ea1c38aDXOvWvJklhxgK4o6I5G1Pg

13 files changed:
ChangeLog
lib/isc/include/isc/file.h
lib/isc/include/isc/util.h
lib/isc/inet_ntop.c
lib/isc/inet_pton.c
lib/isc/result.c
lib/isc/unix/file.c
libntp/msyslog.c
libntp/snprintf.c
ntpd/ntp_io.c
ntpd/refclock_nmea.c
ntpd/refclock_parse.c
ntpd/refclock_wwvb.c

index 142ef84e63b9e3557f29f82399c7fc53c4a46909..b5ffaa502cad17c0f5d0d9b8614ff2bf5eedcb26 100644 (file)
--- 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 <stenn@ntp.org>
 * [Bug 2035] ntpq -c mrulist sleeps 1 sec between queries, not 5 msec.
 * Documentation updates from Dave Mills.
index c9457343e0555a82c6dda78650ae8bff6f3a2fc6..ffa633284b9e10e9bf8fc28b8961e1efabe89bd2 100644 (file)
 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.
  *
index 8a3b95d9da36f1b21b7306f6e3faad44f7c57446..82abbed88b8b942ac9e30cf61a50491aad9ddcba 100644 (file)
@@ -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
index 8b7931bab4010cb53e4ab0f05a07898175770ee2..49e4776e25f1027e0691c264ae3ce1372f3e7bea 100644 (file)
@@ -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);
index cd5bb79b53ba430a74e8e6d2783e511ff661d3a8..66b5de0bf4d2895c297ecabb4324f5412ce7c3df 100644 (file)
@@ -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)
index 571358054e8f9b60a75cafbcdde42f57f66f35e6..9e2015f69bef31f41570890eff22973e684e92f2 100644 (file)
@@ -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));
 }
index 5a07bd0d4c0f6f037c87f461a32810c05b01460b..a127ea7dbffaf8c1001c86d1aa5c3dadeedea861 100644 (file)
@@ -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));
index f1b67c958c19c4f5065c0a5903f316f955b9e1ff..8ed9dc4e75369c47faa4f052070ad84257ef2b44 100644 (file)
@@ -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
index 9a72eb2de7e4c5926cd66be767f8b622e3ea6fab..2b6a37473e1f2d240f49ffec7aaa37b53044b413 100644 (file)
@@ -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);
 
index ce9492d891b130c33ab902b8665142e0f861425d..f5f78b9f0aaf1b88606e1cf51d8f21f7e7c2a663 100644 (file)
@@ -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
index ac7cfa721fb999b4982d00045e6be5d728e78d59..240de5a6f1254ee97b0b965026b76d0ccf3a7e7e 100644 (file)
@@ -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
index 046a1d62b5edd802c7c4e662cbc9bce4a06aa549..8f20ab721095cda477c52ee647ff162542487a5d 100644 (file)
@@ -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 !)
index 8472f8697179363c5aa432fc022ba0b742e7774e..75897fcc550b18ccded679d876525072f52e55a2 100644 (file)
@@ -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