[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b96317e1-2aa6-4e04-bd9e-6fb2ce49c417@paulmck-laptop>
Date: Mon, 1 Jul 2024 07:01:30 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Marco Elver <elver@...gle.com>
Cc: Thorsten Blum <thorsten.blum@...lux.com>, dvyukov@...gle.com,
kasan-dev@...glegroups.com, linux-kernel@...r.kernel.org,
David.Laight@...lab.com
Subject: Re: [PATCH v3] kcsan: Use min() to fix Coccinelle warning
On Mon, Jul 01, 2024 at 10:07:29AM +0200, Marco Elver wrote:
> On Sun, 30 Jun 2024 at 22:03, Thorsten Blum <thorsten.blum@...lux.com> wrote:
> >
> > Fixes the following Coccinelle/coccicheck warning reported by
> > minmax.cocci:
> >
> > WARNING opportunity for min()
> >
> > Use size_t instead of int for the result of min().
> >
> > Compile-tested with CONFIG_KCSAN=y.
> >
> > Reviewed-by: Marco Elver <elver@...gle.com>
> > Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> > ---
> > Changes in v2:
> > - Add const and remove redundant parentheses as suggested by Marco Elver
> > - Link to v1: https://lore.kernel.org/linux-kernel/20240623220606.134718-2-thorsten.blum@toblux.com/
> >
> > Changes in v3:
> > - Remove const again after feedback from David Laight
>
> I think I was clear that the removal of const was not needed in this
> case, and my preference was to keep const.
>
> While general and _constructive_ comments are helpful and appreciated,
> this level of nit-picking and bikeshedding about 'const' is a complete
> and utter waste of time. I'm sorry, but I'm rather allergic to this
> level of time-wasting.
>
> As KCSAN maintainer, I'm just going to say I prefer v2.
>
> > - Link to v2: https://lore.kernel.org/linux-kernel/20240624175727.88012-2-thorsten.blum@toblux.com/
>
> [+Cc Paul]
>
> Paul, if possible kindly pick v2 of this patch into the KCSAN tree:
> https://lore.kernel.org/linux-kernel/20240624175727.88012-2-thorsten.blum@toblux.com/
I have queued v2 of this patch, which is as shown below. Please let me
know if anything needs adjustment. If things go well, this should make
the upcoming merge window.
Thanx, Paul
------------------------------------------------------------------------
commit 613b072fe9b3aa11410937498c98b7ac6d7c9d5a
Author: Thorsten Blum <thorsten.blum@...lux.com>
Date: Mon Jun 24 19:57:28 2024 +0200
kcsan: Use min() to fix Coccinelle warning
Fixes the following Coccinelle/coccicheck warning reported by
minmax.cocci:
WARNING opportunity for min()
Use const size_t instead of int for the result of min().
Compile-tested with CONFIG_KCSAN=y.
Reviewed-by: Marco Elver <elver@...gle.com>
Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
diff --git a/kernel/kcsan/debugfs.c b/kernel/kcsan/debugfs.c
index 1d1d1b0e4248..53b21ae30e00 100644
--- a/kernel/kcsan/debugfs.c
+++ b/kernel/kcsan/debugfs.c
@@ -225,7 +225,7 @@ debugfs_write(struct file *file, const char __user *buf, size_t count, loff_t *o
{
char kbuf[KSYM_NAME_LEN];
char *arg;
- int read_len = count < (sizeof(kbuf) - 1) ? count : (sizeof(kbuf) - 1);
+ const size_t read_len = min(count, sizeof(kbuf) - 1);
if (copy_from_user(kbuf, buf, read_len))
return -EFAULT;
Powered by blists - more mailing lists