Skip to content
  • NeilBrown's avatar
    staging: lustre: add container_of_safe() · 05e6557b
    NeilBrown authored
    
    
    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.
    
    Signed-off-by: default avatarNeilBrown <neilb@suse.com>
    Reviewed-by: default avatarJames Simmons <jsimmons@infradead.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    05e6557b