void * cast cleanup

Lists: pgsql-patches
From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: void * cast cleanup
Date: 2004-09-26 23:52:45
Message-ID: 1096242764.25688.689.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

This patch removes a few instances where a pointer type was being
explicitly cast to void * when pfree() was called. Per ANSI89, this is
redundant: any pointer type can be assigned to void *, and vice versa,
without a cast. IMHO adding the cast in this case serves only to make
the code harder to read.

Would anyone object to me removing some more void * casts, e.g. the
parameters to the various _walker functions?

-Neil

Attachment Content-Type Size
void-pointer-cleanup-1.patch text/x-patch 3.9 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: void * cast cleanup
Date: 2004-09-27 01:49:35
Message-ID: 16711.1096249775@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Neil Conway <neilc(at)samurai(dot)com> writes:
> Would anyone object to me removing some more void * casts, e.g. the
> parameters to the various _walker functions?

I'm a bit concerned about introducing warnings from not-quite-with-it
compilers. Are there any still out there that would treat this as a
bogus conversion?

While I agree that casting pfree's argument is just pedantry, I'm not
quite sold on the proposition for less well-known functions such as
the _walker family. You could take it as a flag that "yes I mean to
treat this pointer as a generic object now". I'm not dead set on that
reasoning but it's something to think about.

Any other opinions out there?

regards, tom lane


From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: void * cast cleanup
Date: 2004-09-27 02:03:07
Message-ID: 1096250587.25688.724.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Mon, 2004-09-27 at 11:49, Tom Lane wrote:
> I'm a bit concerned about introducing warnings from not-quite-with-it
> compilers. Are there any still out there that would treat this as a
> bogus conversion?

Since this is defined by C89, I think we're okay assuming the compiler
can handle it. In any case, a compiler that doesn't comply with the
standard on this issue would issue hundreds of warnings/errors trying to
compile the rest of the PG tree (e.g. the vast majority of pfree() call
sites that don't bother with the explicit cast), so I don't think this
change makes the situation materially worse.

-Neil


From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: void * cast cleanup
Date: 2004-09-27 04:02:36
Message-ID: 1096257756.25688.728.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Mon, 2004-09-27 at 09:52, Neil Conway wrote:
> This patch removes a few instances where a pointer type was being
> explicitly cast to void * when pfree() was called.

Patch applied to HEAD.

-Neil