cppcheck: zpool_main.c possible null pointer dereference

Explicitly check for NULL to satisfy cppcheck that "val" can never
be NULL when passed to printf().  This looks like a false positive
since is_blank_str() can never take the false conditional branch
when passed a NULL.  But there's no harm in adding the extra check.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #11508
This commit is contained in:
Brian Behlendorf 2021-01-22 15:03:56 -08:00
parent 62d4287f27
commit 7454d2bb8d
1 changed files with 1 additions and 1 deletions

View File

@ -2010,7 +2010,7 @@ zpool_print_cmd(vdev_cmd_data_list_t *vcdl, const char *pool, char *path)
* Mark empty values with dashes to make output
* awk-able.
*/
if (is_blank_str(val))
if (val == NULL || is_blank_str(val))
val = "-";
printf("%*s", vcdl->uniq_cols_width[j], val);