]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Declare load_hosts() as returning HostsFileLoadResult.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 4 May 2026 22:33:06 +0000 (18:33 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 4 May 2026 22:33:06 +0000 (18:33 -0400)
This function returns some value of enum HostsFileLoadResult,
but for reasons lost in the development process was declared to
return "int".  Fix that, for clarity and so that our typedefs
collection tooling sees the typedef as used.  Also fix the
variable that the sole call assigns into.  Move the typedef
to the header file that declares load_hosts() to avoid creating
header dependency problems.

Discussion: https://postgr.es/m/359138.1777922557@sss.pgh.pa.us

src/backend/libpq/be-secure-common.c
src/backend/libpq/be-secure-openssl.c
src/include/libpq/hba.h
src/include/libpq/libpq.h

index ad04bedaa1de1d46700345a5c0c587f3e998b5fb..6ec887b8a4771dc3a2d1aa511359379e1ce9537a 100644 (file)
@@ -361,7 +361,7 @@ parse_hosts_line(TokenizedAuthLine *tok_line, int elevel)
  * the hosts configuration failed to load, the err_msg variable may have more
  * information in case it was passed as non-NULL.
  */
-int
+HostsFileLoadResult
 load_hosts(List **hosts, char **err_msg)
 {
        FILE       *file;
index f64b2787f668b4557b0eaebd915d8580c4724af2..b978497b5d4b22d6b9855ab504c6f36016916258 100644 (file)
@@ -156,7 +156,7 @@ be_tls_init(bool isServerStart)
        MemoryContext host_memcxt = NULL;
        MemoryContextCallback *host_memcxt_cb;
        char       *err_msg = NULL;
-       int                     res;
+       HostsFileLoadResult res;
        struct hosts *new_hosts;
        SSL_CTX    *context = NULL;
        int                     ssl_ver_min = -1;
index 29e2a6c5b3db18e6c4523b1ef752c087dcf25b25..4aa6258a345160964e500c97cf90eebaaac72a22 100644 (file)
@@ -165,15 +165,6 @@ typedef struct HostsLine
        void       *ssl_ctx;            /* associated SSL_CTX* for the above settings */
 } HostsLine;
 
-typedef enum HostsFileLoadResult
-{
-       HOSTSFILE_LOAD_OK = 0,
-       HOSTSFILE_LOAD_FAILED,
-       HOSTSFILE_EMPTY,
-       HOSTSFILE_MISSING,
-       HOSTSFILE_DISABLED,
-} HostsFileLoadResult;
-
 /*
  * TokenizedAuthLine represents one line lexed from an authentication
  * configuration file.  Each item in the "fields" list is a sub-list of
index c9b934d2321553dc1d1e70ac8ec015015266e924..d15073a0a93a0e12aa7d7b0d64ff7a4e511add4d 100644 (file)
@@ -156,6 +156,15 @@ enum ssl_protocol_versions
        PG_TLS1_3_VERSION,
 };
 
+typedef enum HostsFileLoadResult
+{
+       HOSTSFILE_LOAD_OK = 0,
+       HOSTSFILE_LOAD_FAILED,
+       HOSTSFILE_EMPTY,
+       HOSTSFILE_MISSING,
+       HOSTSFILE_DISABLED,
+} HostsFileLoadResult;
+
 /*
  * prototypes for functions in be-secure-common.c
  */
@@ -164,6 +173,6 @@ extern int  run_ssl_passphrase_command(const char *cmd, const char *prompt,
                                                                           char *buf, int size);
 extern bool check_ssl_key_file_permissions(const char *ssl_key_file,
                                                                                   bool isServerStart);
-extern int     load_hosts(List **hosts, char **err_msg);
+extern HostsFileLoadResult load_hosts(List **hosts, char **err_msg);
 
 #endif                                                 /* LIBPQ_H */