Re: Remove useless casts to (void *)

From: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
To: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: Remove useless casts to (void *)
Date: 2025-11-20 18:16:19
Message-ID: CAOYmi+mP7mVcmtvTMtWksHJyftVpXsNuqiyTf6eYx4EhMVg1nQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 20, 2025 at 6:02 AM Aleksander Alekseev
<aleksander(at)tigerdata(dot)com> wrote:
> Here `databuf` has a type (void*). Although the code is correct, it
> replaces an explicit cast (which I read "yes, we know what we are
> doing") with an implicit one.

"Yes, we know what we are doing" is the argument against doing it,
though. There's no upside to telling the compiler that in this case:
if it's correct, the compiler would have done it for you anyway, and
if it's buggy, now the compiler has been told to stay silent.

So +1 on removing unneeded (void *) casts in general, for the sake of
establishing consensus, though I haven't looked at this particular
patch in detail.

--Jacob

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-11-20 18:18:56 Re: pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent
Previous Message Dagfinn Ilmari Mannsåker 2025-11-20 18:02:20 Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)