diff options
| author | Warner Losh <imp@FreeBSD.org> | 2020-10-23 23:56:00 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2020-10-23 23:56:00 +0000 |
| commit | 4e0771b2da184592e35952c8d4fdf8a9a8858ced (patch) | |
| tree | cdf7cd2702ccbbc08e2e2f65cb1392445fd7b858 /lib | |
| parent | 3e7449a37b92e7b5333c4be704a191661f038a9a (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/gen/err.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libc/gen/err.c b/lib/libc/gen/err.c index 4193eca77f60..c536767f1a6b 100644 --- a/lib/libc/gen/err.c +++ b/lib/libc/gen/err.c @@ -161,6 +161,9 @@ warnc(int code, const char *fmt, ...) void vwarnc(int code, const char *fmt, va_list ap) { + static int saved_errno; + + saved_errno = errno; if (err_file == NULL) err_set_file(NULL); fprintf(err_file, "%s: ", _getprogname()); @@ -169,6 +172,7 @@ vwarnc(int code, const char *fmt, va_list ap) fprintf(err_file, ": "); } fprintf(err_file, "%s\n", strerror(code)); + errno = saved_errno; } void @@ -183,10 +187,14 @@ warnx(const char *fmt, ...) void vwarnx(const char *fmt, va_list ap) { + static int saved_errno; + + saved_errno = errno; if (err_file == NULL) err_set_file(NULL); fprintf(err_file, "%s: ", _getprogname()); if (fmt != NULL) vfprintf(err_file, fmt, ap); fprintf(err_file, "\n"); + errno = saved_errno; } |
