[pgpool-general: 7887] Re: Clean up some code using "(expr) ? true : false"

lucy.fnst at fujitsu.com lucy.fnst at fujitsu.com
Mon Nov 22 15:50:35 JST 2021


Hi,

> I think this is not quite correct as jNode->u.integer is int64_t, while value is bool
> *.
> They are different types.
...
> I think this is not quite correct as g_cluster.ipc_auth_needed is bool, while
> strlen() returns size_t. They are different types.

Yes, you're right. I did take a risk modifying it that way.
The easiest solution was not to fix it, so I remade the patch.

Best regards

> -----Original Message-----
> From: Tatsuo Ishii <ishii at sraoss.co.jp>
> Sent: Monday, November 22, 2021 12:50 PM
> To: Lu, Chenyang/陆 晨阳 <lucy.fnst at fujitsu.com>
> Cc: pgpool-general at pgpool.net
> Subject: Re: [pgpool-general: 7885] Re: Clean up some code using "(expr) ? true :
> false"
> 
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgpool2_v2.patch
Type: application/octet-stream
Size: 989 bytes
Desc: pgpool2_v2.patch
URL: <http://www.pgpool.net/pipermail/pgpool-general/attachments/20211122/70dc8e18/attachment.obj>


More information about the pgpool-general mailing list