Refactor BackendFlagsShowFunc(). master
authorTatsuo Ishii <[email protected]>
Wed, 17 Dec 2025 04:10:10 +0000 (13:10 +0900)
committerTatsuo Ishii <[email protected]>
Wed, 17 Dec 2025 04:10:10 +0000 (13:10 +0900)
Previously BackendFlagsShowFunc() and pool_flag_to_str() used almost
identical codes.  To avoid the duplication, let BackendFlagsShowFunc()
to call pool_flag_to_str().

src/config/pool_config_variables.c

index 2c5b9c86d0ee7a7db65fa5221199d68164c1b82a..0a0e483149190e14ca13406c08d0ee2ac0a9c53a 100644 (file)
@@ -4551,25 +4551,8 @@ BackendDataDirShowFunc(int index)
 static const char *
 BackendFlagsShowFunc(int index)
 {
-       static char buffer[1024];
-
        unsigned short flag = g_pool_config.backend_desc->backend_info[index].flag;
-
-       *buffer = '\0';
-
-       if (POOL_ALLOW_TO_FAILOVER(flag))
-               snprintf(buffer, sizeof(buffer), "ALLOW_TO_FAILOVER");
-       else if (POOL_DISALLOW_TO_FAILOVER(flag))
-               snprintf(buffer, sizeof(buffer), "DISALLOW_TO_FAILOVER");
-
-       if (POOL_ALWAYS_PRIMARY & flag)
-       {
-               if (*buffer == '\0')
-                       snprintf(buffer, sizeof(buffer), "ALWAYS_PRIMARY");
-               else
-                       strncat(buffer, "|ALWAYS_PRIMARY", 16);
-       }
-       return buffer;
+       return pool_flag_to_str(flag);
 }
 
 static const char *