From cad4323cd345ec91fbe8d118436d3d50fa53c300 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Wed, 31 Aug 2022 13:06:50 +0200 Subject: Refactor check_ functions to use filehandle for status When reporting failure in check_ functions there is (typically) a text- file mentioned in the error report which contains further details. Some check_ functions kept a separate flag variable to indicate failure, and some just checked the state of the filehandle as it's guaranteed to be open when the check failed. This refactors the functions to consistently do the same check on error reporting. As the error report contains the filepath, it makes more sense to check the filehandle state and skip the flag variable. Reviewed-by: Nathan Bossart Reviewed-by: Bruce Momjian Discussion: https://postgr.es/m/595759F6-625B-4ED7-8125-91AF00437F83@yesql.se --- src/bin/pg_upgrade/function.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/bin/pg_upgrade/function.c') diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c index 70b492cc3a8..93d975864ba 100644 --- a/src/bin/pg_upgrade/function.c +++ b/src/bin/pg_upgrade/function.c @@ -123,7 +123,6 @@ check_loadable_libraries(void) int libnum; int was_load_failure = false; FILE *script = NULL; - bool found = false; char output_path[MAXPGPATH]; prep_status("Checking for presence of required libraries"); @@ -158,7 +157,6 @@ check_loadable_libraries(void) if (PQresultStatus(res) != PGRES_COMMAND_OK) { - found = true; was_load_failure = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) @@ -181,7 +179,7 @@ check_loadable_libraries(void) PQfinish(conn); - if (found) + if (script) { fclose(script); pg_log(PG_REPORT, "fatal"); -- cgit v1.2.3