HomeFreeBSD

Refactor spa_load_l2cache to make build happy

Description

Refactor spa_load_l2cache to make build happy

In case sav->sav_config was NULL the body of the function
would skip the iteration of the l2 cache devices and will
just cleanup the old devices. However, this wasn't very obvious
since the null check was performed after the loop body and after
the old devices were cleaned. Refactor the code so that it's now
obvious when the iteration of the l2cache devices is skipped.

This fixes the following cppcheck warning:

[module/zfs/spa.c:1552]: (error) Possible null pointer dereference: newvdevs

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com>
Closes #5087

Details

Provenance
Nikolay Borisov <n.borisov.lkml@gmail.com>Authored on Sep 10 2016, 8:06 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Sep 12 2016, 7:40 PM
Parents
rG20aa7a4e319d: Free property names with spa_strfree() rather than strfree()
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG67d60824946a: Refactor spa_load_l2cache to make build happy (authored by Nikolay Borisov <n.borisov.lkml@gmail.com>).Sep 12 2016, 7:40 PM