netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SUNRPC: Fix -Wformat-truncation warning
@ 2024-08-14  9:38 kunwu.chan
  2024-08-14 10:28 ` NeilBrown
  2024-08-16 22:01 ` Andrew Lunn
  0 siblings, 2 replies; 7+ messages in thread
From: kunwu.chan @ 2024-08-14  9:38 UTC (permalink / raw)
  To: trondmy, anna, chuck.lever, jlayton, neilb, kolga, Dai.Ngo, tom,
	davem, edumazet, kuba, pabeni
  Cc: linux-nfs, netdev, linux-kernel, Kunwu Chan

From: Kunwu Chan <chentao@kylinos.cn>

Increase size of the servername array to avoid truncated output warning.

net/sunrpc/clnt.c:582:75: error:‘%s’ directive output may be truncated
writing up to 107 bytes into a region of size 48
[-Werror=format-truncation=]
  582 |                   snprintf(servername, sizeof(servername), "%s",
      |                                                             ^~

net/sunrpc/clnt.c:582:33: note:‘snprintf’ output
between 1 and 108 bytes into a destination of size 48
  582 |                     snprintf(servername, sizeof(servername), "%s",
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  583 |                                          sun->sun_path);

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 net/sunrpc/clnt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 09f29a95f2bc..874085f3ed50 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -546,7 +546,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
 		.connect_timeout = args->connect_timeout,
 		.reconnect_timeout = args->reconnect_timeout,
 	};
-	char servername[48];
+	char servername[108];
 	struct rpc_clnt *clnt;
 	int i;
 
-- 
2.40.1


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

end of thread, other threads:[~2024-08-16 23:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-14  9:38 [PATCH] SUNRPC: Fix -Wformat-truncation warning kunwu.chan
2024-08-14 10:28 ` NeilBrown
2024-08-15  8:30   ` Kunwu Chan
2024-08-15 11:39     ` NeilBrown
2024-08-16  1:52       ` Kunwu Chan
2024-08-16 22:01 ` Andrew Lunn
2024-08-16 23:07   ` NeilBrown

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