Some ndctl routines return errno after logging a result. Given the log
message may have updated errno save and restore it over calls to
->log_fn().

Suggested-by: Andy Rudoff <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
---
 util/log.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/util/log.c b/util/log.c
index 8ecaf11d3d64..cc4d7d8aad7c 100644
--- a/util/log.c
+++ b/util/log.c
@@ -14,16 +14,19 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
+#include <errno.h>
 #include <util/log.h>
 
 void do_log(struct log_ctx *ctx, int priority, const char *file,
                int line, const char *fn, const char *format, ...)
 {
        va_list args;
+       int errno_save = errno;
 
        va_start(args, format);
        ctx->log_fn(ctx, priority, file, line, fn, format, args);
        va_end(args);
+       errno = errno_save;
 }
 
 static void log_stderr(struct log_ctx *ctx, int priority, const char *file,

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to