mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl: Return number of allocated tokens in scan_file()
The function returns 0 on success and a negative number on error but is useful to know how many tokens were allocated. This will be used by the BLS parsing code to determine if needs to allocate mor tokens or not to parse the BLS fragments. GitHub-ID: #28 Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
d868ce5ec7
commit
e04acab0ed
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user