Skip to content

Commit ef230a1

Browse files
committed
ndctl, log: save errno over calls to emit log messages
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]>
1 parent a631683 commit ef230a1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

util/log.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@
1414
#include <stdlib.h>
1515
#include <ctype.h>
1616
#include <string.h>
17+
#include <errno.h>
1718
#include <util/log.h>
1819

1920
void do_log(struct log_ctx *ctx, int priority, const char *file,
2021
int line, const char *fn, const char *format, ...)
2122
{
2223
va_list args;
24+
int errno_save = errno;
2325

2426
va_start(args, format);
2527
ctx->log_fn(ctx, priority, file, line, fn, format, args);
2628
va_end(args);
29+
errno = errno_save;
2730
}
2831

2932
static void log_stderr(struct log_ctx *ctx, int priority, const char *file,

0 commit comments

Comments
 (0)