module-rt{kit}: use spa_atoi32 instead of custom strtol

And duplicate the function into rtkit which had a similar but different
approach to it. Let's get both to do the same here.
This commit is contained in:
Peter Hutterer 2021-10-12 13:14:24 +10:00 committed by Wim Taymans
parent 87a1e1534c
commit 696a4b22e9
2 changed files with 12 additions and 7 deletions

View file

@ -501,12 +501,20 @@ static int get_default_int(struct pw_properties *properties, const char *name, i
{
int val;
const char *str;
if ((str = pw_properties_get(properties, name)) != NULL)
val = atoi(str);
else {
bool set_default = true;
if ((str = pw_properties_get(properties, name)) != NULL) {
if (spa_atoi32(str, &val, 10))
set_default = false;
else
pw_log_warn("invalid integer value '%s' of property %s, using default (%d) instead", str, name, def);
}
if (set_default) {
val = def;
pw_properties_setf(properties, name, "%d", val);
}
return val;
}