From 2790d4faaa1b975d0da84300aabf53ebee680536 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Thu, 24 Oct 2019 08:17:19 +0200 Subject: [PATCH] zipl: fix -Wmaybe-uninitialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by GCC 9.2.1 when building with '-Wmaybe-uninitialized'. job.c: In function 'job_get': job.c:1817:14: warning: 'filename' may be used uninitialized in this function [-Wmaybe-uninitialized] 1817 | scan_size = scan_file(filename, &scan); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ job.c:1791:14: note: 'filename' was declared here 1791 | const char *filename; | ^~~~~~~~ Signed-off-by: Marc Hartmayer Reviewed-by: Stefan Haberland Signed-off-by: Jan Höppner --- zipl/src/job.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zipl/src/job.c b/zipl/src/job.c index 03abc329..49926307 100644 --- a/zipl/src/job.c +++ b/zipl/src/job.c @@ -1788,7 +1788,7 @@ get_job_from_config_file(struct command_line* cmdline, struct job_data* job) { struct scan_token* scan; struct scan_token* new_scan; - const char *filename; + const char *filename = NULL; char *blsdir; char* source; int i, rc, scan_size; @@ -1811,6 +1811,10 @@ get_job_from_config_file(struct command_line* cmdline, struct job_data* job) break; } } + if (filename == NULL) { + error_text("No zipl configuration was readable"); + return -1; + } source = ""; } printf("Using config file '%s'%s\n", filename, source);