[CRIU] [PATCH 3/4] print_on_level(): simplify off setting code

Kir Kolyshkin kir at openvz.org
Wed Jan 8 19:36:24 PST 2014


This is a slight refactoring of commit 7de9652, which just simplifies
initialization of 'off' variable, and adds the comment why we do so.
Should make the next patch easier to read.

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 log.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/log.c b/log.c
index 6a9cb0c..8d81932 100644
--- a/log.c
+++ b/log.c
@@ -138,17 +138,16 @@ unsigned int log_get_loglevel(void)
 
 static void __print_on_level(unsigned int loglevel, const char *format, va_list params)
 {
-	int fd, size, ret, off;
+	int fd, size, ret, off = 0;
 
 	if (unlikely(loglevel == LOG_MSG)) {
 		fd = STDOUT_FILENO;
-		off = buf_off;
+		off = buf_off; /* skip dangling timestamp */
 	} else {
 		if (loglevel > current_loglevel)
 			return;
 		fd = log_get_fd();
 		print_ts();
-		off = 0;
 	}
 
 	size  = vsnprintf(buffer + buf_off, PAGE_SIZE - buf_off, format, params);
-- 
1.8.1.4



More information about the CRIU mailing list