Re: [PATCH 08/17] staging: lustre: add container_of_safe()

From: Greg Kroah-Hartman
Date: Mon Apr 23 2018 - 09:17:01 EST


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