cppcheck: (error) Null pointer dereference: who_perm

As indicated by the VERIFY the local who_perm variable can never
be NULL in parse_fs_perm().  Due to the existence of the is_set
conditional, which is always true, cppcheck 1.88 was reporting
a possible NULL reference.  Resolve the issue by removing the
extraneous is_set variable.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732
This commit is contained in:
Brian Behlendorf 2019-12-16 15:49:28 -08:00 committed by Tony Hutter
parent d01290f44d
commit 1c27877ab2

View File

@ -4896,7 +4896,6 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
zfs_deleg_who_type_t perm_type = name[0]; zfs_deleg_who_type_t perm_type = name[0];
char perm_locality = name[1]; char perm_locality = name[1];
const char *perm_name = name + 3; const char *perm_name = name + 3;
boolean_t is_set = B_TRUE;
who_perm_t *who_perm = NULL; who_perm_t *who_perm = NULL;
assert('$' == name[2]); assert('$' == name[2]);
@ -4926,7 +4925,6 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
assert(!"unhandled zfs_deleg_who_type_t"); assert(!"unhandled zfs_deleg_who_type_t");
} }
if (is_set) {
who_perm_node_t *found_node = NULL; who_perm_node_t *found_node = NULL;
who_perm_node_t *node = safe_malloc( who_perm_node_t *node = safe_malloc(
sizeof (who_perm_node_t)); sizeof (who_perm_node_t));
@ -4975,8 +4973,8 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
node = found_node; node = found_node;
who_perm = &node->who_perm; who_perm = &node->who_perm;
} }
}
VERIFY3P(who_perm, !=, NULL); assert(who_perm != NULL);
(void) parse_who_perm(who_perm, nvl2, perm_locality); (void) parse_who_perm(who_perm, nvl2, perm_locality);
} }