From e2843232d520737835747107cf5fc454639f895a Mon Sep 17 00:00:00 2001 From: Eduard Shishkin Date: Tue, 4 Jan 2022 11:15:35 +0100 Subject: [PATCH] zipl/src: make gcc 11.2 happy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a prophylactic check that @filename is not NULL before its dereference. This addresses the following warning (which is a false positive, since stat(2) is never called with NULL file name): job.c:514:13: warning: argument 1 null where non-null expected [-Wnonnull] 514 | if (stat(filename, &stats)) { | ^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/features.h:488, from /usr/include/errno.h:25, from job.c:13: job.c: In function 'check_job_ipl_data': /usr/include/sys/stat.h:227:12: note: in a call to function 'stat' declared 'nonnull' 227 | extern int __REDIRECT_NTH (stat, (const char *__restrict __file, Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/127 Reported-by: Mario Held Signed-off-by: Eduard Shishkin Reviewed-by: Stefan Haberland Reviewed-by: Marc Hartmayer Signed-off-by: Jan Höppner --- zipl/src/job.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zipl/src/job.c b/zipl/src/job.c index 198f8049..10ac0862 100644 --- a/zipl/src/job.c +++ b/zipl/src/job.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "lib/util_arch.h" @@ -495,6 +496,7 @@ set_cl_element(struct component_loc *cl, char *name, const char *filename, cl->size = ALIGN(size, MAXIMUM_PHYSICAL_BLOCKSIZE); return 0; } + assert(filename != NULL); /* Get size */ if (stat(filename, &stats)) { error_reason(strerror(errno));