* open_config_file can be simplified to improve readability and maintenance. * close_config_file can be inlined because the NULL check is superfluous.
Signed-off-by: Michael Adler <[email protected]> --- env/env_api_fat.c | 4 ++-- env/env_config_file.c | 15 +-------------- include/env_config_file.h | 1 - tools/bg_envtools.c | 2 +- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/env/env_api_fat.c b/env/env_api_fat.c index b7540bb..2d698f7 100644 --- a/env/env_api_fat.c +++ b/env/env_api_fat.c @@ -106,7 +106,7 @@ bool read_env(CONFIG_PART *part, BG_ENVDATA *env) } result = false; } - if (close_config_file(config)) { + if (fclose(config)) { VERBOSE(stderr, "Error closing environment file after reading.\n"); }; @@ -151,7 +151,7 @@ bool write_env(CONFIG_PART *part, BG_ENVDATA *env) part->devpath); result = false; } - if (close_config_file(config)) { + if (fclose(config)) { VERBOSE(stderr, "Error closing environment file after writing.\n"); result = false; diff --git a/env/env_config_file.c b/env/env_config_file.c index e270fbb..c9cc99f 100644 --- a/env/env_config_file.c +++ b/env/env_config_file.c @@ -21,12 +21,7 @@ FILE *open_config_file(char *configfilepath, char *mode) { VERBOSE(stdout, "Probing config file at %s.\n", configfilepath); - FILE *config = fopen(configfilepath, mode); - if (config) { - return config; - } else { - return NULL; - } + return fopen(configfilepath, mode); } FILE *open_config_file_from_part(CONFIG_PART *cfgpart, char *mode) @@ -49,14 +44,6 @@ FILE *open_config_file_from_part(CONFIG_PART *cfgpart, char *mode) return config; } -int close_config_file(FILE *config_file_handle) -{ - if (config_file_handle) { - return fclose(config_file_handle); - } - return EINVAL; -} - bool probe_config_file(CONFIG_PART *cfgpart) { bool do_unmount = false; diff --git a/include/env_config_file.h b/include/env_config_file.h index c142a33..57949a0 100644 --- a/include/env_config_file.h +++ b/include/env_config_file.h @@ -18,5 +18,4 @@ FILE *open_config_file_from_part(CONFIG_PART *cfgpart, char *mode); FILE *open_config_file(char *configfilepath, char *mode); -int close_config_file(FILE *config_file_handle); bool probe_config_file(CONFIG_PART *cfgpart); diff --git a/tools/bg_envtools.c b/tools/bg_envtools.c index 786d6c1..2d29e46 100644 --- a/tools/bg_envtools.c +++ b/tools/bg_envtools.c @@ -150,7 +150,7 @@ bool get_env(char *configfilepath, BG_ENVDATA *data) result = false; } - if (close_config_file(config)) { + if (fclose(config)) { VERBOSE(stderr, "Error closing environment file after reading.\n"); }; -- 2.41.0 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20230816105657.267073-1-michael.adler%40siemens.com.
