diff --git a/boards/posix/native_posix/cmdline_common.c b/boards/posix/native_posix/cmdline_common.c index f18ebac015a..00df76f8c15 100644 --- a/boards/posix/native_posix/cmdline_common.c +++ b/boards/posix/native_posix/cmdline_common.c @@ -121,7 +121,7 @@ void cmd_read_option_value(const char *str, void *dest, const char type, const char *option) { int error = 0; - char *endptr; + char *endptr = NULL; switch (type) { case 'b': @@ -162,10 +162,11 @@ void cmd_read_option_value(const char *str, void *dest, const char type, break; default: posix_print_error_and_exit(CMD_TYPE_ERROR, type); + /* Unreachable */ break; } - if (!error && *endptr != 0) { + if (!error && endptr && *endptr != 0) { error = 1; }