Re: remove unnecessary explicit type conversion (to char) for appendStringInfoChar function calls

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: remove unnecessary explicit type conversion (to char) for appendStringInfoChar function calls
Date: 2025-04-12 18:26:29
Message-ID: 8770ae0a-0ee7-450d-83b1-c610cfa2b1ec@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2025-04-11 Fr 1:36 PM, Mahendra Singh Thalor wrote:
> Hi,
> In the current master code, 3 places we are using appendStringInfoChar
> call with explicit type conversion into char. This is not needed as
> all other places, we are using direct character to append.
>
> --- a/src/backend/tcop/postgres.c
> +++ b/src/backend/tcop/postgres.c
> @@ -302,7 +302,7 @@ InteractiveBackend(StringInfo inBuf)
> */
>
> /* Add '\0' to make it look the same as message case. */
> - appendStringInfoChar(inBuf, (char) '\0');
> + appendStringInfoChar(inBuf, '\0');
>
> Here, I am attaching a small patch to fix these 3 type conversions on head.
>

Seems odd that this one is necessary at all. Doesn't a StringInfo always
have a trailing null byte?

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Corey Huinker 2025-04-12 18:44:34 Re: Can we use Statistics Import and Export feature to perforamance testing?
Previous Message Wolfgang Walther 2025-04-12 17:51:06 Buildfarm: Enabling injection points on basilisk/dogfish (Alpine / musl)