Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Casting NULL pointer
@ 2015-08-30 10:09 Andrew Burgess
  2015-08-30 12:33 ` Mark Kettenis
  2015-08-30 16:06 ` Doug Evans
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Burgess @ 2015-08-30 10:09 UTC (permalink / raw)
  To: gdb-patches

There are a small (~26) number of places where the NULL pointer is
cast list this:

    char *wname = (char *) NULL;

This compares to a huge number of places (~726) where we don't use a
cast, so:

    const char *name = NULL;

I've never thought that the cast was either necessary or a
particularly good idea, it feels like unneeded clutter.

I only ask because I was about to push an obvious change that made a
minor edit to a line containing one of the above casts.  I was tempted
to remove the cast, in this case, as a clean up; however, I'm looking
for confirmation that such a change would be viewed as clean up, and
not an unnecessary change.

As a  follow on, given the small number, I'm happy to submit a
patch(es) to remove all of these casts, if its felt that would be a
reasonable clean up.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] Casting NULL pointer
  2015-08-30 10:09 [RFC] Casting NULL pointer Andrew Burgess
@ 2015-08-30 12:33 ` Mark Kettenis
  2015-08-30 13:46   ` Andrew Burgess
  2015-08-30 16:06 ` Doug Evans
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Kettenis @ 2015-08-30 12:33 UTC (permalink / raw)
  To: andrew.burgess; +Cc: gdb-patches

> Date: Sun, 30 Aug 2015 11:09:45 +0100
> From: Andrew Burgess <andrew.burgess@embecosm.com>
> 
> There are a small (~26) number of places where the NULL pointer is
> cast list this:
> 
>     char *wname = (char *) NULL;
> 
> This compares to a huge number of places (~726) where we don't use a
> cast, so:
> 
>     const char *name = NULL;
> 
> I've never thought that the cast was either necessary or a
> particularly good idea, it feels like unneeded clutter.

The cast isn't necessary in assignments like that.  However it is
still necessary to cast NULL to an appropriate pointer when passing it
as an argument to a varargs function.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] Casting NULL pointer
  2015-08-30 12:33 ` Mark Kettenis
@ 2015-08-30 13:46   ` Andrew Burgess
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Burgess @ 2015-08-30 13:46 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

* Mark Kettenis <mark.kettenis@xs4all.nl> [2015-08-30 14:33:00 +0200]:

> > Date: Sun, 30 Aug 2015 11:09:45 +0100
> > From: Andrew Burgess <andrew.burgess@embecosm.com>
> > 
> > There are a small (~26) number of places where the NULL pointer is
> > cast list this:
> > 
> >     char *wname = (char *) NULL;
> > 
> > This compares to a huge number of places (~726) where we don't use a
> > cast, so:
> > 
> >     const char *name = NULL;
> > 
> > I've never thought that the cast was either necessary or a
> > particularly good idea, it feels like unneeded clutter.
> 
> The cast isn't necessary in assignments like that.  However it is
> still necessary to cast NULL to an appropriate pointer when passing it
> as an argument to a varargs function.

Indeed.  Specifically, these are the cases I'm looking at:

    $ grep -re " = ([^)]\+\*\\s\?)\\s\?NULL" binutils-gdb/gdb/*

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] Casting NULL pointer
  2015-08-30 10:09 [RFC] Casting NULL pointer Andrew Burgess
  2015-08-30 12:33 ` Mark Kettenis
@ 2015-08-30 16:06 ` Doug Evans
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Evans @ 2015-08-30 16:06 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On Sun, Aug 30, 2015 at 3:09 AM, Andrew Burgess
<andrew.burgess@embecosm.com> wrote:
> There are a small (~26) number of places where the NULL pointer is
> cast list this:
>
>     char *wname = (char *) NULL;
>
> This compares to a huge number of places (~726) where we don't use a
> cast, so:
>
>     const char *name = NULL;
>
> I've never thought that the cast was either necessary or a
> particularly good idea, it feels like unneeded clutter.
>
> I only ask because I was about to push an obvious change that made a
> minor edit to a line containing one of the above casts.  I was tempted
> to remove the cast, in this case, as a clean up; however, I'm looking
> for confirmation that such a change would be viewed as clean up, and
> not an unnecessary change.
>
> As a  follow on, given the small number, I'm happy to submit a
> patch(es) to remove all of these casts, if its felt that would be a
> reasonable clean up.

Hi.
SGTM


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-30 16:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-30 10:09 [RFC] Casting NULL pointer Andrew Burgess
2015-08-30 12:33 ` Mark Kettenis
2015-08-30 13:46   ` Andrew Burgess
2015-08-30 16:06 ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox