lkml.org 
[lkml]   [2018]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 08/17] staging: lustre: add container_of_safe()
On Thu, Mar 29, 2018 at 03:26:48PM +1100, NeilBrown wrote:
> Luster has a container_of0() function which is similar to
> container_of() but passes an IS_ERR_OR_NULL() pointer through
> unchanged.
> This could be generally useful: bcache at last has a similar function.
>
> Naming is hard, but the precedent set by hlist_entry_safe() suggests
> a _safe suffix might be most consistent.
>
> So add container_of_safe() to kernel.h, and replace all occurrences of
> container_of0() with one of
> - list_first_entry, list_next_entry, when that is a better fit,
> - container_of(), when the pointer is used as a validpointer in
> surrounding code,
> - container_of_safe() when there is no obviously better alternative.

I'm loath to add a kernel.h define for a staging driver, but this does
seem sane. Nice work.

greg k-h

\
 
 \ /
  Last update: 2018-04-23 15:17    [W:0.164 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site