This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa/cli] s/NO_FUNCTION/NULL/
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: Fernando Nasser <fnasser at redhat dot com>
- Cc: Eli Zaretskii <eliz at is dot elta dot co dot il>,gdb-patches at sources dot redhat dot com
- Date: Mon, 21 Jan 2002 13:36:52 -0500
- Subject: Re: [rfa/cli] s/NO_FUNCTION/NULL/
- References: <Pine.SUN.3.91.1020121114951.16755I-100000@is> <3C4C46E8.F48A93D7@redhat.com>
>> IMHO, someone should test this change with the latest versions of GCC,
>> including their development line: they could have their own ideas when
>> you are allowed to pass NULL, especially with all the warning options
>> we use.
My ISO C is pretty rusty, however my memory is that NULL is very very
special. GCC might do be doing some strange things but they won't
extend to things like:
cmd->function.cfunc = NULL;
if (cmd->function.cfunc)
or
if (cmd->function.cfunc == NULL)
With regard to parameters, GDB is fully parameterized so that isn't a
problem.
GDB built with GCC 3.0.3. Using current GCC things died mysteriously
part way through the build.
> Besides, the NO_FUNCTION documents the meaning better than NULL
> (although most people should guess). Maybe you can add a comment
> somewhere nearby.
>
> Any chance Eli's concerns become true and we get a warning because
> NULL is not typed properly? Maybe you would need a cast (in which
> case I would prefer the NO_FUNCTION def.
If we're going to have a cast NULL pointer for cfunc (NO_FUNCTION) then
we're going to need to do similar for every single function pointer in
GDB. I really can't see anyone doing that.
Anyway, per my original e-mail , a quick look through the CLI code
reveals that even the CLI doesn't follow its own convention. The CLI uses:
if (cmd->function.cfunc == NULL)
and
if (cmd->function.cfunc)
intead of:
if (cmd->function.cfunc == NO_FUNCTION)
(the latter occures just once). This leads me to conclude that
NO_FUNCTION ``was simply a good idea at the time''. One of those
conventions that looks good but doesn't actually improve things.
enjoy,
Andrew