Re: Remove useless casts to (void *)

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: Remove useless casts to (void *)
Date: 2025-11-20 14:44:07
Message-ID: aR8pNzL4McASPoWZ@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Aleksander,

On Thu, Nov 20, 2025 at 05:01:49PM +0300, Aleksander Alekseev wrote:
> Hi Bertrand,
>
> > The attached also remove casts that have been added since 7f798aca1d5, the ones
> > in pg_publication.c, lock.c and tuplesortvariants.c.
> >
> > The patch has been generated with the help of the .cocci script [2] (though I
> > manually reviewed and removed some matches that, I think, were not appropriate).
>
> I didn't review the entire patch but one change caught my attention:

Thanks for looking at it!

>
> ```
> - databuf = (void *) ((char *) databuf + avail);
> + databuf = (char *) databuf + avail;
> ```
>
> 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, that's what it is doing and so was 7f798aca1d5.

For example in 7f798aca1d5, you can also see things like:

@@ -858,7 +858,7 @@ setup_firstcall(FuncCallContext *funcctx, HStore *hs,
st = (HStore *) palloc(VARSIZE(hs));
memcpy(st, hs, VARSIZE(hs));

- funcctx->user_fctx = (void *) st;
+ funcctx->user_fctx = st;

Where funcctx->user_fctx is of type (void *) and st is of type (HStore *).

> Personally I don't think this is a good change.

Only this one (because maybe databuf is used twice) or the whole idea of 7f798aca1d5
and this patch?

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2025-11-20 14:50:21 Re: Parallel Apply
Previous Message Robert Haas 2025-11-20 14:30:42 Re: another autovacuum scheduling thread