diff options
Diffstat (limited to 'cli/cli.h')
-rw-r--r-- | cli/cli.h | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -104,8 +104,9 @@ int cli_opt_long_set(struct cli_opt *self, const char *val) struct cli_opt_long *opt = container_of(self, struct cli_opt_long, opt); errno = 0; - opt->value = strtol(val, NULL, 0); - if (errno != 0) + char *endptr; + opt->value = strtol(val, &endptr, 0); + if (errno != 0 || *endptr != '\0') return CLI_RC_BAD_ARGS; return CLI_RC_OK; @@ -133,8 +134,9 @@ int cli_opt_ulong_set(struct cli_opt *self, const char *val) struct cli_opt_ulong *opt = container_of(self, struct cli_opt_ulong, opt); errno = 0; - opt->value = strtoul(val, NULL, 0); - if (errno != 0) + char *endptr; + opt->value = strtoul(val, &endptr, 0); + if (errno != 0 || *endptr != '\0') return CLI_RC_BAD_ARGS; return CLI_RC_OK; |