lora: shell: use strtoul instead of strtoll
Parsed value is expected to be in range (0, UINT32_MAX). Use strtoul instead of strtoll, so we better match its range. In a tested configuration this saves 380 bytes of flash with newlib and arm32 target. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit is contained in:
parent
8aa3dc340d
commit
3c55e1fcf3
1 changed files with 5 additions and 5 deletions
|
@ -71,21 +71,21 @@ static int parse_long_range(long *out, const struct shell *shell,
|
||||||
static int parse_freq(uint32_t *out, const struct shell *shell, const char *arg)
|
static int parse_freq(uint32_t *out, const struct shell *shell, const char *arg)
|
||||||
{
|
{
|
||||||
char *eptr;
|
char *eptr;
|
||||||
long long llval;
|
unsigned long val;
|
||||||
|
|
||||||
llval = strtoll(arg, &eptr, 0);
|
val = strtoul(arg, &eptr, 0);
|
||||||
if (*eptr != '\0') {
|
if (*eptr != '\0') {
|
||||||
shell_error(shell, "Invalid frequency, '%s' is not an integer",
|
shell_error(shell, "Invalid frequency, '%s' is not an integer",
|
||||||
arg);
|
arg);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llval < 0 || llval > UINT32_MAX) {
|
if (val == ULONG_MAX) {
|
||||||
shell_error(shell, "Frequency %lli out of range", llval);
|
shell_error(shell, "Frequency %s out of range", arg);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = (uint32_t)llval;
|
*out = (uint32_t)val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue