lkml.org 
[lkml]   [2014]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [Cocci] spatch for trivial pointer comparison style?
From
Date
On Fri, 2014-11-14 at 07:06 +0100, Julia Lawall wrote:
> On Thu, 13 Nov 2014, Joe Perches wrote:
>
> > I added a checkpatch entry for this.
> > Maybe some cocci test like this would be useful?
> >
> > @@
> > type t;
> > t *p;
> > @@
> > - p == NULL
> > + !p
> >
> > @@
> > type t;
> > t *p;
> > @@
> > - p != NULL
> > + p
> >
> > @@
> > type t;
> > t *p;
> > @@
> > - NULL == p
> > + !p
> >
> > @@
> > type t;
> > t *p;
> > @@
> > - NULL != p
> > + p
>
> This was discussed many years ago. I don't think that the change is
> desirable in all cases. There are functions like kmalloc where NULL means
> failure and !p seems like the reasonable choice. But there maybe other
> cases where NULL is somehow a meaningful value.
>
> Here is a link to the part of the discussion:
>
> https://lkml.org/lkml/2007/7/27/103

Yes, I agree with some of the things Al Viro said
there, but isn't 'type t; t *p;' a subset of
"expression *e"?





\
 
 \ /
  Last update: 2014-11-14 07:41    [W:0.063 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site