mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] module: remove use of uninitialized variable len
@ 2023-04-17 23:09 Tom Rix
  2023-04-17 23:32 ` Luis Chamberlain
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Rix @ 2023-04-17 23:09 UTC (permalink / raw)
  To: mcgrof, nathan, ndesaulniers; +Cc: linux-modules, linux-kernel, llvm, Tom Rix

clang build reports
kernel/module/stats.c:307:34: error: variable
  'len' is uninitialized when used here [-Werror,-Wuninitialized]
        len = scnprintf(buf + 0, size - len,
                                        ^~~
At the start of this sequence, neither the '+ 0', nor the '- len' are needed.
So remove them and fix using 'len' uninitalized.

Fixes: 0d4ab68ce983 ("module: add debug stats to help identify memory pressure")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 kernel/module/stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/module/stats.c b/kernel/module/stats.c
index d9b9bccf4256..f0619170bd3d 100644
--- a/kernel/module/stats.c
+++ b/kernel/module/stats.c
@@ -304,7 +304,7 @@ static ssize_t read_file_mod_stats(struct file *file, char __user *user_buf,
 		return -ENOMEM;
 
 	/* The beginning of our debug preamble */
-	len = scnprintf(buf + 0, size - len, "%25s\t%u\n", "Mods ever loaded", live_mod_count);
+	len = scnprintf(buf, size, "%25s\t%u\n", "Mods ever loaded", live_mod_count);
 
 	len += scnprintf(buf + len, size - len, "%25s\t%u\n", "Mods failed on kread", fkreads);
 
-- 
2.27.0


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

end of thread, other threads:[~2023-04-17 23:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-17 23:09 [PATCH] module: remove use of uninitialized variable len Tom Rix
2023-04-17 23:32 ` Luis Chamberlain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®