From: Zbigniew Jędrzejewski-Szmek Date: Wed, 1 Nov 2017 21:33:26 +0000 (+0100) Subject: journald: unitialized variable access X-Git-Tag: v236~270^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d3e682e124c283be367a4db55b73d491eeb48dc;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index d45c9c22705..1ff4e298491 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);