[sheepdog] [PATCH v2 1/5] logger: add a newline to the end of print format if it is missing

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon Feb 25 16:11:10 CET 2013


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 lib/logger.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/logger.c b/lib/logger.c
index a7aab54..1b0fb15 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -328,6 +328,10 @@ static notrace void dolog(int prio, const char *func, int line,
 
 	gettimeofday(&tv, NULL);
 	len = vsnprintf(str, MAX_MSG_SIZE, fmt, ap);
+	if (len + 1 < MAX_MSG_SIZE && str[len - 1] != '\n') {
+		str[len++] = '\n';
+		str[len] = '\0';
+	}
 
 	if (la) {
 		struct sembuf ops;
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list