mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
topology: avoid to use the atoi() directly when expected
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
9e2bbccfcc
commit
f373bf1f6e
9 changed files with 150 additions and 133 deletions
|
|
@ -21,6 +21,35 @@
|
|||
#include "list.h"
|
||||
#include "tplg_local.h"
|
||||
|
||||
/*
|
||||
* Get integer value
|
||||
*/
|
||||
int tplg_get_integer(snd_config_t *n, int *val, int base)
|
||||
{
|
||||
const char *str;
|
||||
long lval;
|
||||
int err;
|
||||
|
||||
switch (snd_config_get_type(n)) {
|
||||
case SND_CONFIG_TYPE_INTEGER:
|
||||
err = snd_config_get_integer(n, &lval);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (lval < INT_MIN || lval > INT_MAX)
|
||||
return -EINVAL;
|
||||
*val = lval;
|
||||
return err;
|
||||
case SND_CONFIG_TYPE_STRING:
|
||||
err = snd_config_get_string(n, &str);
|
||||
if (err < 0)
|
||||
return err;
|
||||
*val = strtol(str, NULL, base);
|
||||
return 0;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse compound
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue