]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
dbg: save errno from modification in NL_DBG()
authorThomas Haller <thaller@redhat.com>
Thu, 5 Mar 2015 09:28:41 +0000 (10:28 +0100)
committerThomas Haller <thaller@redhat.com>
Thu, 5 Mar 2015 09:30:24 +0000 (10:30 +0100)
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>
include/netlink-private/netlink.h

index 39f4dff688868c416fc9e5920f353cf0511e9932..b06df8bb1431bde5c619a7c9bdf5f73c2b4c363d 100644 (file)
@@ -86,11 +86,14 @@ struct trans_list {
 #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)