public inbox for [email protected]  
help / color / mirror / Atom feed
Refactor BackendFlagsShowFunc()
2+ messages / 1 participants
[nested] [flat]

* Refactor BackendFlagsShowFunc()
@ 2025-12-08 09:23 Tatsuo Ishii <[email protected]>
  2025-12-17 04:12 ` Re: Refactor BackendFlagsShowFunc() Tatsuo Ishii <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Tatsuo Ishii @ 2025-12-08 09:23 UTC (permalink / raw)
  To: [email protected]

Currently BackendFlagsShowFunc() and pool_flag_to_str() use almost
identical codes.  To avoid the duplication, I would like to propose to
let BackendFlagsShowFunc() to call pool_flag_to_str(). Patch attached.

Best regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp


Attachments:

  [application/octet-stream] v1-0001-Refactor-BackendFlagsShowFunc.patch (1.4K, 2-v1-0001-Refactor-BackendFlagsShowFunc.patch)
  download | inline diff:
From 38fd3c142768b0966ea26d2fe147762f54659666 Mon Sep 17 00:00:00 2001
From: Tatsuo Ishii <[email protected]>
Date: Mon, 8 Dec 2025 18:17:30 +0900
Subject: [PATCH v1] Refactor BackendFlagsShowFunc().

BackendFlagsShowFunc() and pool_flag_to_str() use almost identical
codes.  To avoid the duplication, let BackendFlagsShowFunc() to call
pool_flag_to_str().
---
 src/config/pool_config_variables.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/src/config/pool_config_variables.c b/src/config/pool_config_variables.c
index e58771b25..f0e88f351 100644
--- a/src/config/pool_config_variables.c
+++ b/src/config/pool_config_variables.c
@@ -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 *
-- 
2.43.0



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Refactor BackendFlagsShowFunc()
  2025-12-08 09:23 Refactor BackendFlagsShowFunc() Tatsuo Ishii <[email protected]>
@ 2025-12-17 04:12 ` Tatsuo Ishii <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Tatsuo Ishii @ 2025-12-17 04:12 UTC (permalink / raw)
  To: [email protected]

> Currently BackendFlagsShowFunc() and pool_flag_to_str() use almost
> identical codes.  To avoid the duplication, I would like to propose to
> let BackendFlagsShowFunc() to call pool_flag_to_str(). Patch attached.

Patch pushed. Thanks.
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-12-17 04:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-12-08 09:23 Refactor BackendFlagsShowFunc() Tatsuo Ishii <[email protected]>
2025-12-17 04:12 ` Tatsuo Ishii <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox