diff mbox series

[iproute2-next] utils: fix get_integer() logic

Message ID 20230819205448.428253-1-pctammela@mojatatu.com (mailing list archive)
State Accepted
Commit 877f8149d2ed94b6ab412fabaab9fe8d15193db7
Delegated to: David Ahern
Headers show
Series [iproute2-next] utils: fix get_integer() logic | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Pedro Tammela Aug. 19, 2023, 8:54 p.m. UTC
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 <pctammela@mojatatu.com>
---
 lib/utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org Aug. 20, 2023, 6:13 p.m. UTC | #1
Hello:

This patch was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Sat, 19 Aug 2023 17:54:48 -0300 you wrote:
> 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 <pctammela@mojatatu.com>
> 
> [...]

Here is the summary with links:
  - [iproute2-next] utils: fix get_integer() logic
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=877f8149d2ed

You are awesome, thank you!
Mathieu Schroeter Aug. 20, 2023, 8:07 p.m. UTC | #2
Le 19.08.23 à 22:54, Pedro Tammela a écrit :
> 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 <pctammela@mojatatu.com>
> ---
>   lib/utils.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/utils.c b/lib/utils.c
> index efa01668..99ba7a23 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)

my bad

Thank you !
diff mbox series

Patch

diff --git a/lib/utils.c b/lib/utils.c
index efa01668..99ba7a23 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)