Martin Pieuchot([email protected]) on 2016.06.05 20:06:17 +0200:
> On 04/06/16(Sat) 18:33, Sebastian Benoit wrote:
> > Add format attributes to the proper functions and then fix the warning in
> > session.c.
>
> Shouldn't you introduce a log.h instead an make sure all daemons share
> the same log.h and log.c?
That question came up in the past. I can certainly do that.
However, can i put in the attributes first?
In bgpd i missed fatalx(), updated diff.
ok?
diff --git bgpd.h bgpd.h
index 5fa046e..e5145d4 100644
--- bgpd.h
+++ bgpd.h
@@ -989,16 +989,26 @@ struct in6_addr *prefixlen2mask6(u_int8_t prefixlen);
/* log.c */
void log_init(int);
void log_verbose(int);
-void logit(int, const char *, ...);
-void vlog(int, const char *, va_list);
-void log_peer_warn(const struct peer_config *, const char *, ...);
-void log_peer_warnx(const struct peer_config *, const char *, ...);
-void log_warn(const char *, ...);
-void log_warnx(const char *, ...);
-void log_info(const char *, ...);
-void log_debug(const char *, ...);
-void fatal(const char *, ...) __dead;
-void fatalx(const char *) __dead;
+void logit(int, const char *, ...)
+ __attribute__((__format__ (printf, 2, 3)));
+void vlog(int, const char *, va_list)
+ __attribute__((__format__ (printf, 2, 0)));
+void log_peer_warn(const struct peer_config *, const char *, ...)
+ __attribute__((__format__ (printf, 2, 3)));
+void log_peer_warnx(const struct peer_config *, const char *, ...)
+ __attribute__((__format__ (printf, 2, 3)));
+void log_warn(const char *, ...)
+ __attribute__((__format__ (printf, 1, 2)));
+void log_warnx(const char *, ...)
+ __attribute__((__format__ (printf, 1, 2)));
+void log_info(const char *, ...)
+ __attribute__((__format__ (printf, 1, 2)));
+void log_debug(const char *, ...)
+ __attribute__((__format__ (printf, 1, 2)));
+void fatal(const char *, ...) __dead
+ __attribute__((__format__ (printf, 1, 2)));
+void fatalx(const char *) __dead
+ __attribute__((__format__ (printf, 1, 0)));
/* mrt.c */
void mrt_clear_seq(void);
diff --git session.c session.c
index 8c853a1..e736b76 100644
--- session.c
+++ session.c
@@ -2017,7 +2017,7 @@ parse_open(struct peer *peer)
/* check bgpid for validity - just disallow 0 */
if (ntohl(bgpid) == 0) {
- log_peer_warnx(&peer->conf, "peer BGPID %lu unacceptable",
+ log_peer_warnx(&peer->conf, "peer BGPID %u unacceptable",
ntohl(bgpid));
session_notification(peer, ERR_OPEN, ERR_OPEN_BGPID,
NULL, 0);