From c0765342208008299e0df578ca9868fc0c13ae07 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Feb 2018 14:39:27 +1030 Subject: [PATCH] logv: preserve errno. Logging often gets called in error paths, so this is just good hygiene. Also, log_io does this already. Signed-off-by: Rusty Russell --- lightningd/log.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lightningd/log.c b/lightningd/log.c index 1b37243e2..b15a163d5 100644 --- a/lightningd/log.c +++ b/lightningd/log.c @@ -232,6 +232,7 @@ static struct log_entry *new_log_entry(struct log *log, enum log_level level) void logv(struct log *log, enum log_level level, const char *fmt, va_list ap) { + int save_errno = errno; struct log_entry *l = new_log_entry(log, level); l->log = tal_vfmt(l, fmt, ap); @@ -241,6 +242,7 @@ void logv(struct log *log, enum log_level level, const char *fmt, va_list ap) log->lr->print_arg); add_entry(log, l); + errno = save_errno; } void log_io(struct log *log, bool in, const void *data, size_t len)