native_posix: Check pointer before de-referencing it
To avoid a Coverity warning (203449): https://github.com/zephyrproject-rtos/zephyr/issues/18354 Initialize a pointer to NULL, and check it later before de-referencing it. Coverity could not see that posix_print_error_and_exit() never returns even that it ends with exit() Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
parent
43fc6a7eff
commit
469accfbe2
1 changed files with 3 additions and 2 deletions
|
@ -121,7 +121,7 @@ void cmd_read_option_value(const char *str, void *dest, const char type,
|
||||||
const char *option)
|
const char *option)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
char *endptr;
|
char *endptr = NULL;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -162,10 +162,11 @@ void cmd_read_option_value(const char *str, void *dest, const char type,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
posix_print_error_and_exit(CMD_TYPE_ERROR, type);
|
posix_print_error_and_exit(CMD_TYPE_ERROR, type);
|
||||||
|
/* Unreachable */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error && *endptr != 0) {
|
if (!error && endptr && *endptr != 0) {
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue