Remove some useless casts to (void *)

Started by Peter Eisentrautabout 3 years ago3 messageshackers
Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

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.

Attachments:

0001-Remove-useless-casts-to-void-hash_search.patchtext/plain; charset=UTF-8; name=0001-Remove-useless-casts-to-void-hash_search.patchDownload+108-109
0002-Remove-useless-casts-to-void-repalloc.patchtext/plain; charset=UTF-8; name=0002-Remove-useless-casts-to-void-repalloc.patchDownload+13-14
0003-Remove-useless-casts-to-void-memcpy.patchtext/plain; charset=UTF-8; name=0003-Remove-useless-casts-to-void-memcpy.patchDownload+24-25
0004-Remove-useless-casts-to-void-memset.patchtext/plain; charset=UTF-8; name=0004-Remove-useless-casts-to-void-memset.patchDownload+14-16
0005-Remove-useless-casts-to-void-memmove.patchtext/plain; charset=UTF-8; name=0005-Remove-useless-casts-to-void-memmove.patchDownload+2-3
0006-Remove-useless-casts-to-void-memcmp.patchtext/plain; charset=UTF-8; name=0006-Remove-useless-casts-to-void-memcmp.patchDownload+1-2
0007-Remove-useless-casts-to-void-qsort.patchtext/plain; charset=UTF-8; name=0007-Remove-useless-casts-to-void-qsort.patchDownload+59-60
0008-Remove-useless-casts-to-void-bsearch.patchtext/plain; charset=UTF-8; name=0008-Remove-useless-casts-to-void-bsearch.patchDownload+5-6
#2Corey Huinker
corey.huinker@gmail.com
In reply to: Peter Eisentraut (#1)
Re: Remove some useless casts to (void *)

On Thu, Feb 2, 2023 at 5:22 PM Peter Eisentraut <
peter.eisentraut@enterprisedb.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.

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Corey Huinker (#2)
Re: Remove some useless casts to (void *)

On 03.02.23 00:59, Corey Huinker wrote:

On Thu, Feb 2, 2023 at 5:22 PM Peter Eisentraut
<peter.eisentraut@enterprisedb.com
<mailto:peter.eisentraut@enterprisedb.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!