This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Casting NULL pointer
- From: Andrew Burgess <andrew dot burgess at embecosm dot com>
- To: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- Cc: gdb-patches at sourceware dot org
- Date: Sun, 30 Aug 2015 14:46:11 +0100
- Subject: Re: [RFC] Casting NULL pointer
- Authentication-results: sourceware.org; auth=none
- References: <20150830100944 dot GA3916 at embecosm dot com> <201508301233 dot t7UCX0Nv012040 at glazunov dot sibelius dot xs4all dot nl>
* 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