mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 09:27:38 +00:00
flog: Save & restore errno
In some cases on some platforms this could clobber errno, so doing something like aThingThatFailsWithErrno(); FLOG(category, "Some message"); wperror("something"); would print the wrong error (presumably if that category was enabled). In our case it was our (very) old friend RHEL6 returning ESPIPE instead of EISDIR. Fixes #6545.
This commit is contained in:
parent
50e08dc3a0
commit
cc7d9cc2ed
1 changed files with 5 additions and 0 deletions
|
@ -171,11 +171,14 @@ std::vector<const flog_details::category_t *> get_flog_categories();
|
|||
void log_extra_to_flog_file(const wcstring &s);
|
||||
|
||||
/// Output to the fish log a sequence of arguments, separated by spaces, and ending with a newline.
|
||||
/// We save and restore errno because we don't want this to affect other code.
|
||||
#define FLOG(wht, ...) \
|
||||
do { \
|
||||
if (flog_details::category_list_t::g_instance->wht.enabled) { \
|
||||
auto old_errno = errno; \
|
||||
flog_details::g_logger.acquire()->log_args( \
|
||||
flog_details::category_list_t::g_instance->wht, __VA_ARGS__); \
|
||||
errno = old_errno; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -183,8 +186,10 @@ void log_extra_to_flog_file(const wcstring &s);
|
|||
#define FLOGF(wht, ...) \
|
||||
do { \
|
||||
if (flog_details::category_list_t::g_instance->wht.enabled) { \
|
||||
auto old_errno = errno; \
|
||||
flog_details::g_logger.acquire()->log_fmt( \
|
||||
flog_details::category_list_t::g_instance->wht, __VA_ARGS__); \
|
||||
errno = old_errno; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
|
Loading…
Reference in a new issue