All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use kzalloc and rewrite null tests
@ 2014-09-18 20:24 ` Julia Lawall
  0 siblings, 0 replies; 18+ messages in thread
From: Julia Lawall @ 2014-09-18 20:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: kernel-janitors, devel, HPDD-discuss, Greg Kroah-Hartman,
	Andreas Dilger, Oleg Drokin

The following patch removes some kzalloc-related macros and rewrites the
associated null tests to use !x rather than x == NULL.  The complete
semantic patch used for this transformation is as follows:

// <smpl>
@disable unlikely@
expression ptr;
statement S,S1;
@@

  \(OBD_ALLOC\|OBD_ALLOC_WAIT\|OBD_ALLOC_PTR\|OBD_ALLOC_PTR_WAIT\)(ptr,...);
  if (unlikely(
+     !
      ptr
-      == NULL
     )) S else S1

@@
expression ptr;
statement S,S1;
@@

  \(OBD_ALLOC\|OBD_ALLOC_WAIT\|OBD_ALLOC_PTR\|OBD_ALLOC_PTR_WAIT\)(ptr,...);
  if (
+     !
      ptr
-      == NULL
     ) S else S1

@disable unlikely@
expression ptr;
statement S,S1;
@@

  \(OBD_ALLOC\|OBD_ALLOC_WAIT\|OBD_ALLOC_PTR\|OBD_ALLOC_PTR_WAIT\)(ptr,...);
  if (likely(
      ptr
-      != NULL
     )) S else S1

@@
expression ptr;
statement S,S1;
@@

  \(OBD_ALLOC\|OBD_ALLOC_WAIT\|OBD_ALLOC_PTR\|OBD_ALLOC_PTR_WAIT\)(ptr,...);
  if (
      ptr
-      != NULL
     ) S else S1

// -----------------------------------------------------------------------

@@
expression ptr,size;
@@

- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@
expression ptr,size;
@@

- OBD_ALLOC_WAIT(ptr,size)
+ ptr = kzalloc(size, GFP_KERNEL)

@@
expression ptr,size;
@@

- OBD_ALLOC_PTR(ptr)
+ ptr = kzalloc(sizeof(*ptr), GFP_NOFS)

@@
expression ptr,size;
@@

- OBD_ALLOC_PTR_WAIT(ptr,size)
+ ptr = kzalloc(sizeof(*ptr), GFP_KERNEL)
// </smpl>


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

end of thread, other threads:[~2014-09-19 13:50 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-18 20:24 [PATCH] Use kzalloc and rewrite null tests Julia Lawall
2014-09-18 20:24 ` Julia Lawall
2014-09-18 20:24 ` [PATCH] staging: lustre: llite: " Julia Lawall
2014-09-18 20:24   ` Julia Lawall
2014-09-18 23:43   ` Dan Carpenter
2014-09-18 23:43     ` Dan Carpenter
2014-09-19  2:57     ` Drokin, Oleg
2014-09-19  2:57       ` Drokin, Oleg
2014-09-19  3:04       ` [HPDD-discuss] " Drokin, Oleg
2014-09-19  4:45         ` Julia Lawall
2014-09-19  4:45           ` Julia Lawall
2014-09-19 13:36           ` Drokin, Oleg
2014-09-19 13:36             ` Drokin, Oleg
2014-09-19 13:50             ` Julia Lawall
2014-09-19 13:50               ` Julia Lawall
2014-09-19  9:11       ` Dan Carpenter
2014-09-19  9:11         ` Dan Carpenter
2014-09-19 13:27         ` Drokin, Oleg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.