netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2-next] utils: fix get_integer() logic
@ 2023-08-19 20:54 Pedro Tammela
  2023-08-20 18:13 ` patchwork-bot+netdevbpf
  2023-08-20 20:07 ` Mathieu Schroeter
  0 siblings, 2 replies; 3+ messages in thread
From: Pedro Tammela @ 2023-08-19 20:54 UTC (permalink / raw)
  To: netdev; +Cc: stephen, dsahern, Pedro Tammela

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)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2-next] utils: fix get_integer() logic
  2023-08-19 20:54 [PATCH iproute2-next] utils: fix get_integer() logic Pedro Tammela
@ 2023-08-20 18:13 ` patchwork-bot+netdevbpf
  2023-08-20 20:07 ` Mathieu Schroeter
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-20 18:13 UTC (permalink / raw)
  To: Pedro Tammela; +Cc: netdev, stephen, dsahern

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2-next] utils: fix get_integer() logic
  2023-08-19 20:54 [PATCH iproute2-next] utils: fix get_integer() logic Pedro Tammela
  2023-08-20 18:13 ` patchwork-bot+netdevbpf
@ 2023-08-20 20:07 ` Mathieu Schroeter
  1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Schroeter @ 2023-08-20 20:07 UTC (permalink / raw)
  To: Pedro Tammela, netdev; +Cc: stephen, dsahern


[-- Attachment #1.1: Type: text/plain, Size: 880 bytes --]

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 !


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-20 20:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-19 20:54 [PATCH iproute2-next] utils: fix get_integer() logic Pedro Tammela
2023-08-20 18:13 ` patchwork-bot+netdevbpf
2023-08-20 20:07 ` Mathieu Schroeter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).