Re: Remove useless casting to the same type

David Geier <geidav.pg@gmail.com>

From: David Geier <geidav.pg@gmail.com>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, Jacob Champion <jacob.champion@enterprisedb.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-11-25T09:41:54Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Remove useless casting to same type

  2. Simplify hash_xlog_split_allocate_page()

On 25.11.2025 06:46, Bertrand Drouvot wrote:

> I think that the variadic calls in the patch are related to functions that
> can benefits from -Wformat. Let's focus on those: with the cast one would need
> to verify 3 things: variable type, cast and format specifier.
> Without the cast then only 2 things and the compiler can verify these match via
> -Wformat warnings.
> 
> With the cast, the compiler only checks that the cast result matches the format,
> not whether the cast itself is correct, so I'm in favor of removing the cast,
> thoughts?
> 
I agree. It's better if we only have the casts in places where we
actually want to change the type before printing.

Another benefit is that one can directly deduct the type from the log /
print statement by looking at the format specifier.

--
David Geier