diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-27 22:55:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-27 22:55:08 -0400 |
commit | f99a653bd3c48c8be300bd98f89789055f55962d (patch) | |
tree | fe543d53153bd99b29d754c3ee4d0c6bbcab3d10 | |
parent | Merge pull request #1636 from jrouleau/master (diff) | |
parent | restore errno (diff) | |
download | sway-f99a653bd3c48c8be300bd98f89789055f55962d.tar.gz sway-f99a653bd3c48c8be300bd98f89789055f55962d.tar.zst sway-f99a653bd3c48c8be300bd98f89789055f55962d.zip |
Merge pull request #1639 from taiyu-len/save_errno
save errno to avoid issues with it being overwritten in sway_log_errno
-rw-r--r-- | common/log.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/log.c b/common/log.c index 6dc9d743..1b46d58f 100644 --- a/common/log.c +++ b/common/log.c | |||
@@ -127,6 +127,7 @@ void _sway_abort(const char *filename, int line, const char* format, ...) { | |||
127 | } | 127 | } |
128 | 128 | ||
129 | void sway_log_errno(log_importance_t verbosity, char* format, ...) { | 129 | void sway_log_errno(log_importance_t verbosity, char* format, ...) { |
130 | int errsv = errno; | ||
130 | if (verbosity <= v) { | 131 | if (verbosity <= v) { |
131 | unsigned int c = verbosity; | 132 | unsigned int c = verbosity; |
132 | if (c > sizeof(verbosity_colors) / sizeof(char *) - 1) { | 133 | if (c > sizeof(verbosity_colors) / sizeof(char *) - 1) { |
@@ -145,13 +146,14 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) { | |||
145 | va_end(args); | 146 | va_end(args); |
146 | 147 | ||
147 | fprintf(stderr, ": "); | 148 | fprintf(stderr, ": "); |
148 | fprintf(stderr, "%s", strerror(errno)); | 149 | fprintf(stderr, "%s", strerror(errsv)); |
149 | 150 | ||
150 | if (colored && isatty(STDERR_FILENO)) { | 151 | if (colored && isatty(STDERR_FILENO)) { |
151 | fprintf(stderr, "\x1B[0m"); | 152 | fprintf(stderr, "\x1B[0m"); |
152 | } | 153 | } |
153 | fprintf(stderr, "\n"); | 154 | fprintf(stderr, "\n"); |
154 | } | 155 | } |
156 | errno = errsv; | ||
155 | } | 157 | } |
156 | 158 | ||
157 | bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) { | 159 | bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) { |