* [PATCH] mm/kmemleak: fix errors/warnings for coding style
@ 2024-10-14 18:39 Pintu Kumar
2024-10-17 9:40 ` Catalin Marinas
0 siblings, 1 reply; 3+ messages in thread
From: Pintu Kumar @ 2024-10-14 18:39 UTC (permalink / raw)
To: akpm, catalin.marinas, linux-mm, linux-kernel
Cc: skhan, pintu.ping, Pintu Kumar
There are several errors/warnings reported by checkpatch.
Fix all of the positive once as below:
- Use #include <linux/processor.h> instead of <asm/processor.h>
- Missing a blank lines after declarations
- Prefer 'unsigned int' to bare use of 'unsigned'
- else should follow close brace '}'
Signed-off-by: Pintu Kumar <quic_pintu@quicinc.com>
---
mm/kmemleak.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 0400f5e8ac60..11f92bb7b206 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * mm/kmemleak.c
- *
* Copyright (C) 2008 ARM Limited
* Written by Catalin Marinas <catalin.marinas@arm.com>
*
@@ -95,7 +93,7 @@
#include <linux/crc32.h>
#include <asm/sections.h>
-#include <asm/processor.h>
+#include <linux/processor.h>
#include <linux/atomic.h>
#include <linux/kasan.h>
@@ -373,6 +371,7 @@ static void print_unreferenced(struct seq_file *seq,
for (i = 0; i < nr_entries; i++) {
void *ptr = (void *)entries[i];
+
warn_or_seq_printf(seq, " [<%pK>] %pS\n", ptr, ptr);
}
}
@@ -1711,6 +1710,7 @@ static void kmemleak_scan(void)
rcu_read_lock();
for_each_process_thread(g, p) {
void *stack = try_get_task_stack(p);
+
if (stack) {
scan_block(stack, stack + THREAD_SIZE, NULL);
put_task_stack(p);
@@ -1817,6 +1817,7 @@ static int kmemleak_scan_thread(void *arg)
*/
if (first_run) {
signed long timeout = msecs_to_jiffies(SECS_FIRST_SCAN * 1000);
+
first_run = 0;
while (timeout && !kthread_should_stop())
timeout = schedule_timeout_interruptible(timeout);
@@ -2062,7 +2063,7 @@ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,
else if (strncmp(buf, "scan=off", 8) == 0)
stop_scan_thread();
else if (strncmp(buf, "scan=", 5) == 0) {
- unsigned secs;
+ unsigned int secs;
unsigned long msecs;
ret = kstrtouint(buf + 5, 0, &secs);
@@ -2179,8 +2180,7 @@ static int __init kmemleak_boot_config(char *str)
else if (strcmp(str, "on") == 0) {
kmemleak_skip_disable = 1;
stack_depot_request_early_init();
- }
- else
+ } else
return -EINVAL;
return 0;
}
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/kmemleak: fix errors/warnings for coding style
2024-10-14 18:39 [PATCH] mm/kmemleak: fix errors/warnings for coding style Pintu Kumar
@ 2024-10-17 9:40 ` Catalin Marinas
2024-10-17 17:23 ` Pintu Agarwal
0 siblings, 1 reply; 3+ messages in thread
From: Catalin Marinas @ 2024-10-17 9:40 UTC (permalink / raw)
To: Pintu Kumar; +Cc: akpm, linux-mm, linux-kernel, skhan, pintu.ping
On Tue, Oct 15, 2024 at 12:09:18AM +0530, Pintu Kumar wrote:
> There are several errors/warnings reported by checkpatch.
> Fix all of the positive once as below:
> - Use #include <linux/processor.h> instead of <asm/processor.h>
> - Missing a blank lines after declarations
> - Prefer 'unsigned int' to bare use of 'unsigned'
> - else should follow close brace '}'
I wouldn't bother fixing up the style in existing code, it just makes
backporting fixes harder.
> @@ -2179,8 +2180,7 @@ static int __init kmemleak_boot_config(char *str)
> else if (strcmp(str, "on") == 0) {
> kmemleak_skip_disable = 1;
> stack_depot_request_early_init();
> - }
> - else
> + } else
> return -EINVAL;
> return 0;
According to the coding style doc, the 'else' branch also needs braces
here.
--
Catalin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/kmemleak: fix errors/warnings for coding style
2024-10-17 9:40 ` Catalin Marinas
@ 2024-10-17 17:23 ` Pintu Agarwal
0 siblings, 0 replies; 3+ messages in thread
From: Pintu Agarwal @ 2024-10-17 17:23 UTC (permalink / raw)
To: Catalin Marinas; +Cc: Pintu Kumar, akpm, linux-mm, linux-kernel, skhan
Hi Catalin,
On Thu, 17 Oct 2024 at 15:10, Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Tue, Oct 15, 2024 at 12:09:18AM +0530, Pintu Kumar wrote:
> > There are several errors/warnings reported by checkpatch.
> > Fix all of the positive once as below:
> > - Use #include <linux/processor.h> instead of <asm/processor.h>
> > - Missing a blank lines after declarations
> > - Prefer 'unsigned int' to bare use of 'unsigned'
> > - else should follow close brace '}'
>
> I wouldn't bother fixing up the style in existing code, it just makes
> backporting fixes harder.
>
Thank you so much for your review.
Yes, I agree but I see that this keeps growing.
In 5.15 kernel there were 10 warnings:
total: 0 errors, 10 warnings, 2010 lines checked
But now in the 6.12 kernel it becomes 20.
total: 1 errors, 20 warnings, 2253 lines checked
This means new warnings were introduced while the old ones still remain.
Thus I thought it's better to reduce it.
> > @@ -2179,8 +2180,7 @@ static int __init kmemleak_boot_config(char *str)
> > else if (strcmp(str, "on") == 0) {
> > kmemleak_skip_disable = 1;
> > stack_depot_request_early_init();
> > - }
> > - else
> > + } else
> > return -EINVAL;
> > return 0;
>
> According to the coding style doc, the 'else' branch also needs braces
> here.
Oh yes, thanks for pointing this out.
Unfortunately checkpatch does not report this.
But I tried adding braces and no issues either.
I will push the new patchset with this change.
Thanks,
Pintu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-17 17:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-14 18:39 [PATCH] mm/kmemleak: fix errors/warnings for coding style Pintu Kumar
2024-10-17 9:40 ` Catalin Marinas
2024-10-17 17:23 ` Pintu Agarwal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox