]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: do not clobber errno
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 3 Sep 2018 10:17:46 +0000 (12:17 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 4 Sep 2018 11:57:19 +0000 (13:57 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/log.h

index a7f72b4c77bcf0fd00ce5884f7c03050e3af693c..43199bea533b555babb33175e02db1c8f954840c 100644 (file)
@@ -276,6 +276,7 @@ ATTR_UNUSED static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
 {                                                                              \
        if (lxc_log_priority_is_enabled(acategory, LXC_LOG_LEVEL_##LEVEL)) {    \
                va_list va_ref;                                                 \
+               int saved_errno;                                                \
                struct lxc_log_event evt = {                                    \
                        .category       = (acategory)->name,                    \
                        .priority       = LXC_LOG_LEVEL_##LEVEL,                \
@@ -287,12 +288,14 @@ ATTR_UNUSED static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo,       \
                 * without restrictions. So let's use it for our                \
                 * logging stamps.                                              \
                 */                                                             \
+               saved_errno = errno;                                            \
                (void)clock_gettime(CLOCK_REALTIME, &evt.timestamp);            \
                                                                                \
                va_start(va_ref, format);                                       \
                evt.vap = &va_ref;                                              \
                __lxc_log(acategory, &evt);                                     \
                va_end(va_ref);                                                 \
+               errno = saved_errno;                                            \
        }                                                                       \
 }