netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tools: ynl: error check scanf() in a sample
@ 2024-08-28 17:36 Jakub Kicinski
  2024-08-28 18:02 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jakub Kicinski @ 2024-08-28 17:36 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, Jakub Kicinski, donald.hunter, sdf,
	martin.lau, ast, nicolas.dichtel

Someone reported on GitHub that the YNL NIPA test is failing
when run locally. The test builds the tools, and it hits:

  netdev.c:82:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  82 | scanf("%d", &ifindex);

I can't repro this on my setups but error seems clear enough.

Link: https://github.com/linux-netdev/nipa/discussions/37
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: donald.hunter@gmail.com
CC: sdf@fomichev.me
CC: martin.lau@kernel.org
CC: ast@kernel.org
CC: nicolas.dichtel@6wind.com
---
 tools/net/ynl/samples/netdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/net/ynl/samples/netdev.c b/tools/net/ynl/samples/netdev.c
index 3e7b29bd55d5..22609d44c89a 100644
--- a/tools/net/ynl/samples/netdev.c
+++ b/tools/net/ynl/samples/netdev.c
@@ -79,7 +79,10 @@ int main(int argc, char **argv)
 		goto err_close;
 
 	printf("Select ifc ($ifindex; or 0 = dump; or -2 ntf check): ");
-	scanf("%d", &ifindex);
+	if (scanf("%d", &ifindex) != 1) {
+		fprintf(stderr, "Error: unable to parse input\n");
+		goto err_destroy;
+	}
 
 	if (ifindex > 0) {
 		struct netdev_dev_get_req *req;
@@ -119,6 +122,7 @@ int main(int argc, char **argv)
 
 err_close:
 	fprintf(stderr, "YNL: %s\n", ys->err.msg);
+err_destroy:
 	ynl_sock_destroy(ys);
 	return 2;
 }
-- 
2.46.0


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

* Re: [PATCH net-next] tools: ynl: error check scanf() in a sample
  2024-08-28 17:36 [PATCH net-next] tools: ynl: error check scanf() in a sample Jakub Kicinski
@ 2024-08-28 18:02 ` Simon Horman
  2024-08-29 19:43   ` Jakub Kicinski
  2024-08-29  7:21 ` Nicolas Dichtel
  2024-08-29 19:50 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2024-08-28 18:02 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, donald.hunter, sdf, martin.lau,
	ast, nicolas.dichtel

On Wed, Aug 28, 2024 at 10:36:09AM -0700, Jakub Kicinski wrote:
> Someone reported on GitHub that the YNL NIPA test is failing
> when run locally. The test builds the tools, and it hits:
> 
>   netdev.c:82:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
>   82 | scanf("%d", &ifindex);
> 
> I can't repro this on my setups but error seems clear enough.
> 
> Link: https://github.com/linux-netdev/nipa/discussions/37
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Thanks, I have a similar patch in my local-queue.

I was able to reproduce the problem on Ubuntu 22.04,
although not on Fedora 40 or Debian Trixie.

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH net-next] tools: ynl: error check scanf() in a sample
  2024-08-28 17:36 [PATCH net-next] tools: ynl: error check scanf() in a sample Jakub Kicinski
  2024-08-28 18:02 ` Simon Horman
@ 2024-08-29  7:21 ` Nicolas Dichtel
  2024-08-29 19:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: Nicolas Dichtel @ 2024-08-29  7:21 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, edumazet, pabeni, donald.hunter, sdf, martin.lau, ast

Le 28/08/2024 à 19:36, Jakub Kicinski a écrit :
> Someone reported on GitHub that the YNL NIPA test is failing
> when run locally. The test builds the tools, and it hits:
> 
>   netdev.c:82:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
>   82 | scanf("%d", &ifindex);
> 
> I can't repro this on my setups but error seems clear enough.
> 
> Link: https://github.com/linux-netdev/nipa/discussions/37
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

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

* Re: [PATCH net-next] tools: ynl: error check scanf() in a sample
  2024-08-28 18:02 ` Simon Horman
@ 2024-08-29 19:43   ` Jakub Kicinski
  2024-08-29 20:52     ` Simon Horman
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2024-08-29 19:43 UTC (permalink / raw)
  To: Simon Horman
  Cc: davem, netdev, edumazet, pabeni, donald.hunter, sdf, martin.lau,
	ast, nicolas.dichtel

On Wed, 28 Aug 2024 19:02:46 +0100 Simon Horman wrote:
> I was able to reproduce the problem on Ubuntu 22.04,
> although not on Fedora 40 or Debian Trixie.

Thanks for the info! Made me pause and consider putting the fix
in net, but it's just a warning..

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

* Re: [PATCH net-next] tools: ynl: error check scanf() in a sample
  2024-08-28 17:36 [PATCH net-next] tools: ynl: error check scanf() in a sample Jakub Kicinski
  2024-08-28 18:02 ` Simon Horman
  2024-08-29  7:21 ` Nicolas Dichtel
@ 2024-08-29 19:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-29 19:50 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, donald.hunter, sdf, martin.lau,
	ast, nicolas.dichtel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 28 Aug 2024 10:36:09 -0700 you wrote:
> Someone reported on GitHub that the YNL NIPA test is failing
> when run locally. The test builds the tools, and it hits:
> 
>   netdev.c:82:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
>   82 | scanf("%d", &ifindex);
> 
> I can't repro this on my setups but error seems clear enough.
> 
> [...]

Here is the summary with links:
  - [net-next] tools: ynl: error check scanf() in a sample
    https://git.kernel.org/netdev/net-next/c/3d8806f37d31

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] 6+ messages in thread

* Re: [PATCH net-next] tools: ynl: error check scanf() in a sample
  2024-08-29 19:43   ` Jakub Kicinski
@ 2024-08-29 20:52     ` Simon Horman
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2024-08-29 20:52 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, donald.hunter, sdf, martin.lau,
	ast, nicolas.dichtel

On Thu, Aug 29, 2024 at 12:43:15PM -0700, Jakub Kicinski wrote:
> On Wed, 28 Aug 2024 19:02:46 +0100 Simon Horman wrote:
> > I was able to reproduce the problem on Ubuntu 22.04,
> > although not on Fedora 40 or Debian Trixie.
> 
> Thanks for the info! Made me pause and consider putting the fix
> in net, but it's just a warning..

Yes, it made me pause about sending my version of the patch.
But I think it is worth fixing.

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

end of thread, other threads:[~2024-08-29 20:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 17:36 [PATCH net-next] tools: ynl: error check scanf() in a sample Jakub Kicinski
2024-08-28 18:02 ` Simon Horman
2024-08-29 19:43   ` Jakub Kicinski
2024-08-29 20:52     ` Simon Horman
2024-08-29  7:21 ` Nicolas Dichtel
2024-08-29 19:50 ` patchwork-bot+netdevbpf

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