Evaluating the logging statement might overwrite the errno. Save and
restore it so that NL_DBG() preserves the errno.
Signed-off-by: Thomas Haller <thaller@redhat.com>
#ifdef NL_DEBUG
#define NL_DBG(LVL,FMT,ARG...) \
do { \
- if (LVL <= nl_debug) \
+ if (LVL <= nl_debug) { \
+ int _errsv = errno; \
fprintf(stderr, \
"DBG<" #LVL ">%20s:%-4u %s: " FMT, \
__FILE__, __LINE__, \
__PRETTY_FUNCTION__, ##ARG); \
+ errno = _errsv; \
+ } \
} while (0)
#else /* NL_DEBUG */
#define NL_DBG(LVL,FMT,ARG...) do { } while(0)