]> git.ipfire.org Git - thirdparty/systemd.git/commit
journald: unitialized variable access
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 1 Nov 2017 21:33:26 +0000 (22:33 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 1 Nov 2017 22:08:21 +0000 (23:08 +0100)
commit1d3e682e124c283be367a4db55b73d491eeb48dc
tree85e41886444986efc1e499b29ea981c9e0c5fad6
parentac097c841e05bcc96da7f369682b56164671eec8
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