summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-02-14 00:53:27 +0100
committerDavid Lamparter <equinox@diac24.net>2021-02-23 16:56:58 +0100
commit2621bb8b8dee4222da22bbc5c8036de70af096fb (patch)
tree21ced8d6c99135a923380e4be8e40ee0ef91d777 /lib
parentbuild: extract xrefs (diff)
downloadfrr-2621bb8b8dee4222da22bbc5c8036de70af096fb.tar.xz
frr-2621bb8b8dee4222da22bbc5c8036de70af096fb.zip
lib/xref: record log message format args
Apparently you can do `#__VA_ARGS__` and it actually does something sensible, so here we go recording the format parameters for log messages into the xref. This allows some more checking in xrelfo.py, e.g. hints to use `%pFX` and co. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/subdir.am8
-rw-r--r--lib/zlog.h3
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/subdir.am b/lib/subdir.am
index 96d5fcba3..38d1a3f77 100644
--- a/lib/subdir.am
+++ b/lib/subdir.am
@@ -448,9 +448,15 @@ am__v_XRELFO_ = $(am__v_XRELFO_$(AM_DEFAULT_VERBOSITY))
am__v_XRELFO_0 = @echo " XRELFO " $@;
am__v_XRELFO_1 =
+if DEV_BUILD
+XRELFO_FLAGS = -Wlog-format -Wlog-args
+else
+XRELFO_FLAGS =
+endif
+
SUFFIXES += .xref
%.xref: % $(CLIPPY)
- $(AM_V_XRELFO) $(CLIPPY) $(top_srcdir)/python/xrelfo.py -Wlog-format -o $@ $<
+ $(AM_V_XRELFO) $(CLIPPY) $(top_srcdir)/python/xrelfo.py $(XRELFO_FLAGS) -o $@ $<
# dependencies added in python/makefile.py
frr.xref:
diff --git a/lib/zlog.h b/lib/zlog.h
index 3e86aa134..4fdb47bb9 100644
--- a/lib/zlog.h
+++ b/lib/zlog.h
@@ -44,6 +44,7 @@ struct xref_logmsg {
const char *fmtstring;
uint32_t priority;
uint32_t ec;
+ const char *args;
};
struct xrefdata_logmsg {
@@ -97,6 +98,7 @@ static inline void zlog_ref(const struct xref_logmsg *xref,
.xref = XREF_INIT(XREFT_LOGMSG, &_xrefdata, __func__), \
.fmtstring = (msg), \
.priority = (prio), \
+ .args = (#__VA_ARGS__), \
}; \
XREF_LINK(_xref.xref); \
zlog_ref(&_xref, (msg), ##__VA_ARGS__); \
@@ -122,6 +124,7 @@ static inline void zlog_ref(const struct xref_logmsg *xref,
.fmtstring = (msg), \
.priority = (prio), \
.ec = (ec_), \
+ .args = (#__VA_ARGS__), \
}; \
XREF_LINK(_xref.xref); \
zlog_ref(&_xref, "[EC %u] " msg, ec_, ##__VA_ARGS__); \