Remove some useless casts to (void *)

Lists: pgsql-hackers
From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Remove some useless casts to (void *)
Date: 2023-02-02 22:22:27
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

I have found that in some corners of the code some calls to standard C
functions are decorated with casts to (void *) for no reason, and this
code pattern then gets copied around. I have gone through and cleaned
this up a bit, in the attached patches.

The involved functions are: repalloc, memcpy, memset, memmove, memcmp,
qsort, bsearch

Also hash_search(), for which there was a historical reason (the
argument used to be char *), but not anymore.

Attachment Content-Type Size
0001-Remove-useless-casts-to-void-hash_search.patch text/plain 40.2 KB
0002-Remove-useless-casts-to-void-repalloc.patch text/plain 7.0 KB
0003-Remove-useless-casts-to-void-memcpy.patch text/plain 10.2 KB
0004-Remove-useless-casts-to-void-memset.patch text/plain 5.4 KB
0005-Remove-useless-casts-to-void-memmove.patch text/plain 1.1 KB
0006-Remove-useless-casts-to-void-memcmp.patch text/plain 767 bytes
0007-Remove-useless-casts-to-void-qsort.patch text/plain 25.8 KB
0008-Remove-useless-casts-to-void-bsearch.patch text/plain 2.0 KB

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Remove some useless casts to (void *)
Date: 2023-02-02 23:59:44
Message-ID: CADkLM=edJ4DBQQn1jZcDs9Lhn+s3o5P7PT3y3y_QRPcwQ8s3SA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Feb 2, 2023 at 5:22 PM Peter Eisentraut <
peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:

> I have found that in some corners of the code some calls to standard C
> functions are decorated with casts to (void *) for no reason, and this
> code pattern then gets copied around. I have gone through and cleaned
> this up a bit, in the attached patches.
>
> The involved functions are: repalloc, memcpy, memset, memmove, memcmp,
> qsort, bsearch
>
> Also hash_search(), for which there was a historical reason (the
> argument used to be char *), but not anymore.

+1

All code is example code.

Applies.
Passes make check world.


From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Remove some useless casts to (void *)
Date: 2023-02-07 07:09:57
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 03.02.23 00:59, Corey Huinker wrote:
> On Thu, Feb 2, 2023 at 5:22 PM Peter Eisentraut
> <peter(dot)eisentraut(at)enterprisedb(dot)com
> <mailto:peter(dot)eisentraut(at)enterprisedb(dot)com>> wrote:
>
> I have found that in some corners of the code some calls to standard C
> functions are decorated with casts to (void *) for no reason, and this
> code pattern then gets copied around.  I have gone through and cleaned
> this up a bit, in the attached patches.
>
> The involved functions are: repalloc, memcpy, memset, memmove, memcmp,
> qsort, bsearch
>
> Also hash_search(), for which there was a historical reason (the
> argument used to be char *), but not anymore.
>
>
> +1

committed

> All code is example code.

I like that one!