[pgpool-general: 7886] Re: Clean up some code using "(expr) ? true : false"
Tatsuo Ishii
ishii at sraoss.co.jp
Mon Nov 22 13:50:16 JST 2021
Thank you for the patch.
> attachment
> diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c
> index aac6968..60a3adb 100644
> --- a/src/protocol/pool_proto_modules.c
> +++ b/src/protocol/pool_proto_modules.c
> @@ -1717,7 +1717,7 @@ Describe(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend,
> ereport(DEBUG1,
> (errmsg("Describe: waiting for main node completing the query")));
>
> - nowait = (SL_MODE ? true : false);
> + nowait = SL_MODE;
Good catch.
> pool_set_query_in_progress();
> pool_extended_send_and_wait(query_context, "D", len, contents, 1, MAIN_NODE_ID, nowait);
> diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c
> index 4660132..b5ba131 100644
> --- a/src/query_cache/pool_memqcache.c
> +++ b/src/query_cache/pool_memqcache.c
> @@ -2004,7 +2004,7 @@ pool_reset_memqcache_buffer(bool reset_dml_oids)
> bool
> pool_is_shmem_cache(void)
> {
> - return (pool_config->memqcache_method == SHMEM_CACHE) ? true : false;
> + return pool_config->memqcache_method == SHMEM_CACHE;
> }
Good catch.
> /*
> diff --git a/src/utils/json.c b/src/utils/json.c
> index 319c8fd..9aeeb50 100644
> --- a/src/utils/json.c
> +++ b/src/utils/json.c
> @@ -1167,7 +1167,7 @@ json_get_bool_value_for_key(json_value * source, const char *key, bool *value)
> /* for older version compatibility, We use int for encoding bool values */
> if (jNode->type == json_integer || jNode->type == json_boolean)
> {
> - *value = jNode->u.integer ? true : false;
> + *value = jNode->u.integer;
I think this is not quite correct as jNode->u.integer is int64_t, while value is bool *.
They are different types.
> }
> else
> return -1;
> diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c
> index d00fa1d..495786b 100644
> --- a/src/watchdog/watchdog.c
> +++ b/src/watchdog/watchdog.c
> @@ -806,7 +806,7 @@ wd_cluster_initialize(void)
> g_cluster.ipc_commands = NULL;
> g_cluster.localNode->state = WD_DEAD;
> g_cluster.clusterCommands = NULL;
> - g_cluster.ipc_auth_needed = strlen(pool_config->wd_authkey) ? true : false;
> + g_cluster.ipc_auth_needed = strlen(pool_config->wd_authkey);
I think this is not quite correct as g_cluster.ipc_auth_needed is
bool, while strlen() returns size_t. They are different types.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
More information about the pgpool-general
mailing list