fb: cfb_shell: use shell_strtol
in cmd_set_kerning
Switch from using direct `strtol` calls to `shell_strtol`. This change leverages the extensive error handling provided by `shell_strtol`. Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This commit is contained in:
parent
06e0b2d1d6
commit
cff8b6092e
1 changed files with 3 additions and 5 deletions
|
@ -340,8 +340,7 @@ static int cmd_set_font(const struct shell *sh, size_t argc, char *argv[])
|
|||
|
||||
static int cmd_set_kerning(const struct shell *sh, size_t argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
char *ep = NULL;
|
||||
int err = 0;
|
||||
long kerning;
|
||||
|
||||
if (!dev) {
|
||||
|
@ -349,9 +348,8 @@ static int cmd_set_kerning(const struct shell *sh, size_t argc, char *argv[])
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
kerning = strtol(argv[1], &ep, 10);
|
||||
if (errno || ep == argv[1]) {
|
||||
kerning = shell_strtol(argv[1], 10, &err);
|
||||
if (err) {
|
||||
shell_error(sh, HELP_INIT);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue