diff mbox series

[37/47] libsemanage: preserve errno during internal logging

Message ID 20241111141706.38039-37-cgoettsche@seltendoof.de (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series [01/47] libsemanage: white space cleanup | expand

Commit Message

Christian Göttsche Nov. 11, 2024, 2:16 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsemanage/src/debug.h | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libsemanage/src/debug.h b/libsemanage/src/debug.h
index a18a95be..506b9db0 100644
--- a/libsemanage/src/debug.h
+++ b/libsemanage/src/debug.h
@@ -23,6 +23,7 @@ 
 #ifndef _SEMANAGE_INTERNAL_DEBUG_H_
 #define _SEMANAGE_INTERNAL_DEBUG_H_
 
+#include <errno.h>
 #include <stdio.h>
 #include <semanage/debug.h>
 #include <sepol/debug.h>
@@ -36,6 +37,8 @@ 
 	          channel_arg, func_arg, ...) do {         \
 	                                                   \
         if ((handle_arg)->msg_callback) {                  \
+                int errsv__ = errno;                       \
+                                                           \
                 (handle_arg)->msg_fname = func_arg;        \
                 (handle_arg)->msg_channel = channel_arg;   \
                 (handle_arg)->msg_level = level_arg;       \
@@ -43,6 +46,8 @@ 
                 (handle_arg)->msg_callback(                \
                         (handle_arg)->msg_callback_arg,    \
                         handle_arg, __VA_ARGS__);          \
+                                                           \
+                errno = errsv__;                           \
         }                                                  \
 } while(0)