Re: remove obsolete NULL casts

From: Neil Conway <neilc(at)samurai(dot)com>
To: Kurt Roeckx <Q(at)ping(dot)be>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: remove obsolete NULL casts
Date: 2004-01-06 17:17:30
Message-ID: 87vfnpov2t.fsf@mailbox.samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Kurt Roeckx <Q(at)ping(dot)be> writes:
> In src/backend/port/darwin/system.c you replaced:
>
> execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
>
> By:
> execl(_PATH_BSHELL, "sh", "-c", command, NULL);
>
> I think that is one of the exceptions where you do have to cast it,
> because the type is unknown. You can only remove the cast when you
> actually know what pointer type it is.

Ah, good catch! Upon further investigation, you're completely correct:
technically, you need to cast the NULL literal to a pointer type in a
function call if (a) there is no prototype for the function, or (b)
the function is a varargs function (which execl() is).

I'd imagine it would only make a difference on a machine where the
null pointer is represented by a non-zero bit pattern (i.e. it
shouldn't make a difference on any modern machine), but we should do
this correctly, of course. Interesting -- you learn something new
every day :-)

I won't bother posting an updated patch, but I'll include your fix in
the patch when I apply it. Thanks again.

-Neil

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2004-01-06 17:27:19 Re: make "wal_debug" GUC var a boolean
Previous Message Bruce Momjian 2004-01-06 10:43:29 Re: Alter Table phase 1 -- Please apply to 7.5