From b225ef58fb8a4f19479aa22cd62cb38a1791a972 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 28 Aug 2019 19:50:35 +0900 Subject: [PATCH 1/2] nsenter: minor clean up Signed-off-by: Akihiro Suda --- libcontainer/nsenter/nsexec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libcontainer/nsenter/nsexec.c b/libcontainer/nsenter/nsexec.c index 3b08c5e3..e227c93f 100644 --- a/libcontainer/nsenter/nsexec.c +++ b/libcontainer/nsenter/nsexec.c @@ -50,9 +50,6 @@ enum sync_t { #define JUMP_CHILD 0xA0 #define JUMP_INIT 0xA1 -/* JSON buffer. */ -#define JSON_MAX 4096 - /* Assume the stack grows down, so arguments should be above it. */ struct clone_t { /* From 0bc069d7959aad74d751e6f0ca5d8cca555f25cf Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 28 Aug 2019 19:56:10 +0900 Subject: [PATCH 2/2] nsenter: fix clang-tidy warning nsexec.c:148:3: warning: Initialized va_list 'args' is leaked [clang-analyzer-valist.Unterminated] Signed-off-by: Akihiro Suda --- libcontainer/nsenter/nsexec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libcontainer/nsenter/nsexec.c b/libcontainer/nsenter/nsexec.c index e227c93f..07265683 100644 --- a/libcontainer/nsenter/nsexec.c +++ b/libcontainer/nsenter/nsexec.c @@ -145,11 +145,11 @@ static void write_log_with_info(const char *level, const char *function, int lin va_start(args, format); if (vsnprintf(message, sizeof(message), format, args) < 0) - return; - va_end(args); + goto done; - if (dprintf(logfd, "{\"level\":\"%s\", \"msg\": \"%s:%d %s\"}\n", level, function, line, message) < 0) - return; + dprintf(logfd, "{\"level\":\"%s\", \"msg\": \"%s:%d %s\"}\n", level, function, line, message); +done: + va_end(args); } #define write_log(level, fmt, ...) \