From: Pedro Tammela Date: Sat, 19 Aug 2023 20:54:48 +0000 (-0300) Subject: utils: fix get_integer() logic X-Git-Tag: v6.6.0~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=877f8149d2ed94b6ab412fabaab9fe8d15193db7;p=thirdparty%2Fiproute2.git utils: fix get_integer() logic After 3a463c15, get_integer() doesn't return the converted value and always writes 0 in 'val' in case of success. Fix the logic so it writes the converted value in 'val'. Fixes: 3a463c15 ("Add get_long utility and adapt get_integer accordingly" Signed-off-by: Pedro Tammela Signed-off-by: David Ahern --- diff --git a/lib/utils.c b/lib/utils.c index efa01668d..99ba7a233 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -142,7 +142,8 @@ int get_integer(int *val, const char *arg, int base) { long res; - res = get_long(NULL, arg, base); + if (get_long(&res, arg, base) < 0) + return -1; /* Outside range of int */ if (res < INT_MIN || res > INT_MAX)