This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Casting NULL pointer


* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]