From 1d3e682e124c283be367a4db55b73d491eeb48dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 1 Nov 2017 22:33:26 +0100 Subject: [PATCH] journald: unitialized variable access ../src/journal/journald-native.c:341:13: warning: variable 'context' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (ucred && pid_is_valid(ucred->pid)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/journal/journald-native.c:350:42: note: uninitialized use occurs here context, ucred, tv, label, label_len); ^~~~~~~ ../src/journal/journald-native.c:335:31: note: initialize the variable 'context' to silence this warning ClientContext *context; ^ = NULL Very nice reporting! Functions that we call can handle context == NULL, so it's enough to simply initialize the variable. --- src/journal/journald-native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index d45c9c2..1ff4e29 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -332,7 +332,7 @@ void server_process_native_message( const char *label, size_t label_len) { size_t remaining = buffer_size; - ClientContext *context; + ClientContext *context = NULL; int r; assert(s); -- 2.7.4