Provide the necessary hints for gcc -Wformat to work on our printf-like
authorpacman <pacman>
Tue, 17 Oct 2000 22:57:50 +0000 (22:57 +0000)
committerpacman <pacman>
Tue, 17 Oct 2000 22:57:50 +0000 (22:57 +0000)
functions, and fix a couple of format string bugs that were exposed by the
resulting warnings.

src/include/libradius.h
src/include/radiusd.h
src/main/radiusd.c

index 8ecefdb..cc90ec7 100644 (file)
@@ -195,9 +195,17 @@ int                userparse(char *buffer, VALUE_PAIR **first_pair);
  *     Error functions.
  */
 #ifdef _LIBRADIUS
-void           librad_log(const char *, ...);
+void           librad_log(const char *, ...)
+#ifdef __GNUC__
+               __attribute__ ((format (printf, 1, 2)))
 #endif
-void           librad_perror(const char *, ...);
+;
+#endif
+void           librad_perror(const char *, ...)
+#ifdef __GNUC__
+               __attribute__ ((format (printf, 1, 2)))
+#endif
+;
 extern char    librad_errstr[];
 extern int     librad_dodns;
 extern int     librad_debug;
index 9472e6f..5b7321f 100644 (file)
@@ -202,8 +202,16 @@ NAS                *nas_findbyname(char *nasname);
 void           version(void);
 
 /* log.c */
-int            radlog(int, const char *, ...);
-int            log_debug(const char *, ...);
+int            radlog(int, const char *, ...)
+#ifdef __GNUC__
+               __attribute__ ((format (printf, 2, 3)))
+#endif
+;
+int            log_debug(const char *, ...)
+#ifdef __GNUC__
+               __attribute__ ((format (printf, 1, 2)))
+#endif
+;
 
 /* pam.c */
 #ifdef WITH_PAM
index eec0254..80d9dfd 100644 (file)
@@ -1499,8 +1499,9 @@ static int rad_clean_list(time_t curtime)
                                 *      currently 'alive' list of
                                 *      requests.
                                 */
-                               DEBUG2("Cleaning up request ID %d with timestamp %08x",
-                                      curreq->packet->id, curreq->timestamp);
+                               DEBUG2("Cleaning up request ID %d with timestamp %08lx",
+                                      curreq->packet->id,
+                                      (unsigned long)curreq->timestamp);
                                prevreq = curreq->prev;
                                if (request_list[id].request_count == 0) {
                                  DEBUG("HORRIBLE ERROR!!!");
@@ -1745,8 +1746,9 @@ static REQUEST *rad_check_list(REQUEST *request)
                                 *      currently 'alive' list of
                                 *      requests.
                                 */
-                       DEBUG2("Cleaning up request ID %d with timestamp %08x",
-                              curreq->packet->id, curreq->timestamp);
+                       DEBUG2("Cleaning up request ID %d with timestamp %08lx",
+                              curreq->packet->id,
+                              (unsigned long)curreq->timestamp);
                        prevreq = curreq->prev;
                        if (request_list[id].request_count == 0) {
                                DEBUG("HORRIBLE ERROR!!!");