zipl/src: make gcc 11.2 happy

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 <mario.held@de.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Eduard Shishkin
2022-01-04 11:15:35 +01:00
committed by Jan Höppner
parent b79d17d233
commit e2843232d5

View File

@@ -19,6 +19,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <assert.h>
#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));