diff --git a/zipl/src/job.c b/zipl/src/job.c index b06a4824..9d5f00b6 100644 --- a/zipl/src/job.c +++ b/zipl/src/job.c @@ -1732,7 +1732,7 @@ get_job_from_config_file(struct command_line* cmdline, struct job_data* job) struct scan_token* new_scan; char* filename; char* source; - int rc; + int rc, scan_size; /* Read configuration file */ if (cmdline->config != NULL) { @@ -1750,10 +1750,10 @@ get_job_from_config_file(struct command_line* cmdline, struct job_data* job) source = ""; } printf("Using config file '%s'%s\n", filename, source); - rc = scan_file(filename, &scan); - if (rc) { + scan_size = scan_file(filename, &scan); + if (scan_size <= 0) { error_text("Config file '%s'", filename); - return rc; + return scan_size; } if ((cmdline->menu == NULL) && (cmdline->section == NULL)) { rc = scan_check_defaultboot(scan); diff --git a/zipl/src/scan.c b/zipl/src/scan.c index 7465d6cc..adb288e0 100644 --- a/zipl/src/scan.c +++ b/zipl/src/scan.c @@ -538,9 +538,9 @@ scan_free(struct scan_token* array) #define INITIAL_ARRAY_LENGTH 40 -/* Scan file FILENAME for tokens. Upon success, return zero and set TOKEN - * to point to a NULL-terminated array of scan_tokens, i.e. the token id - * of the last token is 0. Return non-zero otherwise. */ +/* Scan file FILENAME for tokens. Upon success, return the number allocated + * tokens and set TOKEN to point to a NULL-terminated array of scan_tokens, + * i.e. the token id of the last token is 0. Return non-zero otherwise. */ int scan_file(const char* filename, struct scan_token** token) { @@ -623,11 +623,13 @@ scan_file(const char* filename, struct scan_token** token) } } misc_free_file_buffer(&file); - if (rc) + if (rc) { scan_free(array); - else - *token = array; - return rc; + return rc; + } + + *token = array; + return size; }