]> git.proxmox.com Git - mirror_zfs.git/commitdiff
cppcheck: zpool_main.c possible null pointer dereference
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 22 Jan 2021 23:03:56 +0000 (15:03 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 27 Jan 2021 00:11:46 +0000 (16:11 -0800)
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

cmd/zpool/zpool_main.c

index 3ac3728667f314f649f3d630aa9f3367f87c3b7e..50adc0add605b854f137943c2b2259b37cc31ff0 100644 (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);