[PATCH 1/2] sysdep/unix/log: reinitialize the static logging structs
Andreas Rammhold
andreas at rammhold.de
Tue Nov 24 09:08:30 CET 2020
This is required as they otherwise point to already (invalid) existing
lists and add_tail will fail (during a debug build). Re-initializing
these should be fine as the list they belong to is being re-initialized
on entry to the very same function. This became mandatory as of
baac7009063d the next and prev pointers of nodes in a list are checked
against NULL in debug builds.
---
sysdep/unix/log.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c
index e24322c6..14a0e875 100644
--- a/sysdep/unix/log.c
+++ b/sysdep/unix/log.c
@@ -341,7 +341,8 @@ default_log_list(int initial, const char **syslog_name)
#ifdef HAVE_SYSLOG_H
if (!dbgf)
{
- static struct log_config lc_syslog = { .mask = ~0 };
+ static struct log_config lc_syslog;
+ lc_syslog = (struct log_config){ .mask = ~0 };
add_tail(&log_list, &lc_syslog.n);
*syslog_name = bird_name;
}
@@ -349,15 +350,22 @@ default_log_list(int initial, const char **syslog_name)
if (dbgf && (dbgf != stderr))
{
- static struct log_config lc_debug = { .mask = ~0 };
- lc_debug.fh = dbgf;
+ static struct log_config lc_debug;
+ lc_debug = (struct log_config){
+ .mask = ~0,
+ .fh = dbgf
+ };
add_tail(&log_list, &lc_debug.n);
}
if (initial || (dbgf == stderr))
{
- static struct log_config lc_stderr = { .mask = ~0, .terminal_flag = 1};
- lc_stderr.fh = stderr;
+ static struct log_config lc_stderr;
+ lc_stderr = (struct log_config){
+ .mask = ~0,
+ .terminal_flag = 1,
+ .fh = stderr
+ };
add_tail(&log_list, &lc_stderr.n);
}
--
2.29.2
More information about the Bird-users
mailing list