1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cov: add explicit NULL pointer check

Make obvious to coverity strcmp() is not getting NULL pointer.
This commit is contained in:
Zdenek Kabelac 2021-09-20 10:24:30 +02:00
parent 752a9ec4b4
commit ebd150366f
4 changed files with 8 additions and 7 deletions

View File

@ -932,7 +932,7 @@ static int _check_value_differs_from_default(struct cft_check_handle *handle,
} else { } else {
str = v_def ? v_def->v.str str = v_def ? v_def->v.str
: cfg_def_get_default_value(handle->cmd, def, CFG_TYPE_STRING, NULL); : cfg_def_get_default_value(handle->cmd, def, CFG_TYPE_STRING, NULL);
diff = strcmp(str, v->v.str); diff = str ? strcmp(str, v->v.str) : 0;
} }
break; break;
case DM_CFG_EMPTY_ARRAY: case DM_CFG_EMPTY_ARRAY:

View File

@ -6426,9 +6426,10 @@ static const struct command *_find_command(const struct command *commands,
{ {
int i; int i;
for (i = 0; commands[i].name; i++) if (name)
if (!strcmp(commands[i].name, name)) for (i = 0; commands[i].name; i++)
return commands + i; if (!strcmp(commands[i].name, name))
return commands + i;
return NULL; return NULL;
} }

View File

@ -240,7 +240,7 @@ static unsigned _filter(const char *pattern, struct test_details **tests, unsign
} }
for (i = 0; i < nr; i++) for (i = 0; i < nr; i++)
if (!regexec(&rx, tests[i]->path, 0, NULL, 0)) if (tests[i] && !regexec(&rx, tests[i]->path, 0, NULL, 0))
tests[found++] = tests[i]; tests[found++] = tests[i];
regfree(&rx); regfree(&rx);

View File

@ -4015,9 +4015,9 @@ int main(int argc, char *argv[])
factor_common_options(); factor_common_options();
if (primary) if (primary && cmdname)
r = _print_man(cmdname, desfile, secondary); r = _print_man(cmdname, desfile, secondary);
else if (secondary) { else if (secondary && cmdname) {
r = 1; r = 1;
_print_man_secondary(cmdname); _print_man_secondary(cmdname);
} else if (check) { } else if (check) {