[CRIU] [PATCH 2/9] logging: make sure to not change errno

Kir Kolyshkin kir at openvz.org
Mon Nov 7 13:37:46 PST 2016


Our log functions save errno and restore it. Restoring should be
at the very end of the __print_on_level() function, but
commit 6ae4a97 ("rpc: Report back first error message on failure")
messed with it.

Move errno restore at the end of the function.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 criu/log.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/criu/log.c b/criu/log.c
index 274361f..6bac3a9 100644
--- a/criu/log.c
+++ b/criu/log.c
@@ -227,10 +227,11 @@ static void __print_on_level(unsigned int loglevel, const char *format, va_list
 			break;
 		off += ret;
 	}
-	errno =  __errno;
 
 	if (loglevel == LOG_ERROR)
 		log_note_err(buffer + buf_off);
+
+	errno =  __errno;
 }
 
 void print_on_level(unsigned int loglevel, const char *format, ...)
-- 
2.7.4



More information about the CRIU mailing list