lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-01-09 19:58:02 +01:00
parent 866d911655
commit 9415ce4a14
+6 -6
View File
@@ -22,6 +22,7 @@
#include <libeconf.h>
#endif
#include "atoi/a2i.h"
#include "atoi/str2i.h"
#include "defines.h"
#include "getdef.h"
@@ -233,10 +234,11 @@ bool getdef_bool (const char *item)
* values are handled.
*/
int getdef_num (const char *item, int dflt)
int
getdef_num(const char *item, int dflt)
{
struct itemdef *d;
long val;
int val;
struct itemdef *d;
if (!def_loaded) {
def_load ();
@@ -247,9 +249,7 @@ int getdef_num (const char *item, int dflt)
return dflt;
}
if ( (str2sl(&val, d->value) == -1)
|| (val > INT_MAX)
|| (val < -1)) {
if (a2si(&val, d->value, NULL, 0, -1, INT_MAX) == -1) {
fprintf (shadow_logfd,
_("configuration error - cannot parse %s value: '%s'"),
item, d->value);