Commit 3d8806f3 authored by Jakub Kicinski's avatar Jakub Kicinski

tools: ynl: error check scanf() in a sample

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/37Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Reviewed-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Link: https://patch.msgid.link/20240828173609.2951335-1-kuba@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d64d11b7
...@@ -79,7 +79,10 @@ int main(int argc, char **argv) ...@@ -79,7 +79,10 @@ int main(int argc, char **argv)
goto err_close; goto err_close;
printf("Select ifc ($ifindex; or 0 = dump; or -2 ntf check): "); 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) { if (ifindex > 0) {
struct netdev_dev_get_req *req; struct netdev_dev_get_req *req;
...@@ -119,6 +122,7 @@ int main(int argc, char **argv) ...@@ -119,6 +122,7 @@ int main(int argc, char **argv)
err_close: err_close:
fprintf(stderr, "YNL: %s\n", ys->err.msg); fprintf(stderr, "YNL: %s\n", ys->err.msg);
err_destroy:
ynl_sock_destroy(ys); ynl_sock_destroy(ys);
return 2; return 2;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment