diff options
author | Emanuele Di Pascale <emanuele@voltanet.io> | 2021-02-22 10:29:55 +0100 |
---|---|---|
committer | Emanuele Di Pascale <emanuele@voltanet.io> | 2021-02-22 10:38:42 +0100 |
commit | c364a0962b0c7b93ff7f7801ec805e6ea25e1a5a (patch) | |
tree | db03b7e19dbc76b3a2e9fcdc935cf862b719e51c /lib/zlog.h | |
parent | Merge pull request #7444 from sudhanshukumar22/bgp-clean-dampening-issue (diff) | |
download | frr-c364a0962b0c7b93ff7f7801ec805e6ea25e1a5a.tar.xz frr-c364a0962b0c7b93ff7f7801ec805e6ea25e1a5a.zip |
lib: fix c++ usage of zlog
Since some recent commit, building c++ code attempting to use zlog_debug
(or any other level) would fail with the following complaint:
lib/zlog.h:91:3: sorry, unimplemented: non-trivial designated
initializers not supported
};
^
lib/zlog.h:105:26: note: in expansion of macro ‘_zlog_ref’
#define zlog_debug(...) _zlog_ref(LOG_DEBUG, __VA_ARGS__)
This is due to out-of-order initialization of the xrefdata struct
fields. Setting them all in the order in which they are defined
fixes the issue.
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
Diffstat (limited to 'lib/zlog.h')
-rw-r--r-- | lib/zlog.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/zlog.h b/lib/zlog.h index bdf59fa68..3e86aa134 100644 --- a/lib/zlog.h +++ b/lib/zlog.h @@ -84,18 +84,22 @@ static inline void zlog_ref(const struct xref_logmsg *xref, va_end(ap); } -#define _zlog_ref(prio, msg, ...) do { \ +#define _zlog_ref(prio, msg, ...) \ + do { \ static struct xrefdata _xrefdata = { \ + .xref = NULL, \ + .uid = {}, \ .hashstr = (msg), \ - .hashu32 = { (prio), 0 }, \ + .hashu32 = {(prio), 0}, \ }; \ - static const struct xref_logmsg _xref __attribute__((used)) = {\ + static const struct xref_logmsg _xref __attribute__( \ + (used)) = { \ .xref = XREF_INIT(XREFT_LOGMSG, &_xrefdata, __func__), \ .fmtstring = (msg), \ .priority = (prio), \ }; \ XREF_LINK(_xref.xref); \ - zlog_ref(&_xref, (msg), ## __VA_ARGS__); \ + zlog_ref(&_xref, (msg), ##__VA_ARGS__); \ } while (0) #define zlog_err(...) _zlog_ref(LOG_ERR, __VA_ARGS__) @@ -104,19 +108,23 @@ static inline void zlog_ref(const struct xref_logmsg *xref, #define zlog_notice(...) _zlog_ref(LOG_NOTICE, __VA_ARGS__) #define zlog_debug(...) _zlog_ref(LOG_DEBUG, __VA_ARGS__) -#define _zlog_ecref(ec_, prio, msg, ...) do { \ +#define _zlog_ecref(ec_, prio, msg, ...) \ + do { \ static struct xrefdata _xrefdata = { \ + .xref = NULL, \ + .uid = {}, \ .hashstr = (msg), \ - .hashu32 = { (prio), (ec_) }, \ + .hashu32 = {(prio), (ec_)}, \ }; \ - static const struct xref_logmsg _xref __attribute__((used)) = {\ + static const struct xref_logmsg _xref __attribute__( \ + (used)) = { \ .xref = XREF_INIT(XREFT_LOGMSG, &_xrefdata, __func__), \ .fmtstring = (msg), \ .priority = (prio), \ .ec = (ec_), \ }; \ XREF_LINK(_xref.xref); \ - zlog_ref(&_xref, "[EC %u] " msg, ec_, ## __VA_ARGS__); \ + zlog_ref(&_xref, "[EC %u] " msg, ec_, ##__VA_ARGS__); \ } while (0) #define flog_err(ferr_id, format, ...) \ |