Re: Remove useless casting to the same type

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Remove useless casting to the same type
Date: 2025-11-28 08:40:55
Message-ID: 66057689-17e2-4f73-a1f0-6a9ef8f3af40@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 25.11.25 06:46, Bertrand Drouvot wrote:
>> Maybe we should make the code compile cleanly under
>> -Wformat-signedness at some point...
> good idea, will give it a try later on outside the context of this patch.

I test this once in a while and fix the issues that I find. But it's
very picky and you will find difficult to fix problems like the fact
that the signedness of enums is implementation-defined, and so the only
portable fix there would be to add more casts.

I think it could be useful to tighten the source code with respect to
implicit integer conversions, using warnings such as -Wsign-conversion
and -Wconversion as well as -Wformat-signedness. There are surely
hidden overflow or truncation issues similar to CVE-2025-12818 hidden
somewhere. But explicit casts defeat those warnings, so removing
unnecessary casts is a good step on the way there.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-11-28 08:42:50 Re: ON CONFLICT DO SELECT (take 3)
Previous Message Chao Li 2025-11-28 08:34:51 Migrate to autoconf 2.72?