All of lore.kernel.org
 help / color / mirror / Atom feed
* main - lvmlockd: Fix the compilation warning
@ 2021-06-08 14:33 David Teigland
  0 siblings, 0 replies; only message in thread
From: David Teigland @ 2021-06-08 14:33 UTC (permalink / raw)
  To: lvm-devel

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5e17203ff5dd4296760e5dad683e4cc84df2801d
Commit:        5e17203ff5dd4296760e5dad683e4cc84df2801d
Parent:        9759f915e78044667681de395bf2694bd5c7f393
Author:        Leo Yan <leo.yan@linaro.org>
AuthorDate:    Tue Jun 8 14:45:09 2021 +0800
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Tue Jun 8 09:33:26 2021 -0500

lvmlockd: Fix the compilation warning

As SUSE build tool reports the warning:

lvmlockd-core.c: In function 'client_thread_main':
lvmlockd-core.c:4959:37: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Wformat-truncation=]
    snprintf(buf, sizeof(buf), "path[%d]", i);
                                     ^~
lvmlockd-core.c:4959:31: note: directive argument in the range [0, 2147483647]
    snprintf(buf, sizeof(buf), "path[%d]", i);
                               ^~~~~~~~~~

To dismiss the compilation warning, enlarge the array "buf" to 17
bytes to support the max signed integer: string format 6 bytes + signed
integer 10 bytes + terminal char "\0".

Reported-by: Heming Zhao <heming.zhao@suse.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 daemons/lvmlockd/lvmlockd-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index ea76f2214..fef9589b9 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -4780,7 +4780,7 @@ static void client_recv_action(struct client *cl)
 	const char *path;
 	const char *str;
 	struct pvs pvs;
-	char buf[11];	/* p a t h [ x x x x ] \0 */
+	char buf[17];	/* "path[%d]\0", %d outputs signed integer so max to 10 bytes */
 	int64_t val;
 	uint32_t opts = 0;
 	int result = 0;



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-08 14:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 14:33 main - lvmlockd: Fix the compilation warning David Teigland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.