linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remoteproc: fix minmax.cocci warnings
@ 2022-02-08 20:41 Julia Lawall
  2022-02-10 17:58 ` Mathieu Poirier
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2022-02-08 20:41 UTC (permalink / raw)
  To: Wendy Liang, Michal Simek, Ohad Ben-Cohen, Bjorn Andersson,
	Mathieu Poirier
  Cc: linux-remoteproc, linux-kernel, kbuild-all, linux-arm-kernel

From: kernel test robot <lkp@intel.com>

The code seems more readable with min.

Generated by: scripts/coccinelle/misc/minmax.cocci

Fixes: 2b9408d09dc6 ("remoteproc: Add support for peek from remote and acking kick from remote")
CC: Wendy Liang <wendy.liang@xilinx.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>

---

tree:   https://github.com/Xilinx/linux-xlnx xlnx_rebase_v5.15
head:   1183ce490adb103e5e569b8ebd74c50c885ddc05
commit: 2b9408d09dc6367fd2f0820f0c7beab69e9aed56 [550/872] remoteproc: Add support for peek from remote and acking kick from remote
:::::: branch date: 7 days ago
:::::: commit date: 7 days ago

 remoteproc_sysfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -241,7 +241,7 @@ static ssize_t kick_store(struct device
 	size_t cpy_len;

 	(void)attr;
-	cpy_len = count <= sizeof(id) ? count : sizeof(id);
+	cpy_len = min(count, sizeof(id));
 	memcpy((char *)(&id), buf, cpy_len);

 	if (rproc->ops->kick)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] remoteproc: fix minmax.cocci warnings
  2022-02-08 20:41 [PATCH] remoteproc: fix minmax.cocci warnings Julia Lawall
@ 2022-02-10 17:58 ` Mathieu Poirier
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Poirier @ 2022-02-10 17:58 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Wendy Liang, Michal Simek, Ohad Ben-Cohen, Bjorn Andersson,
	linux-remoteproc, linux-kernel, kbuild-all, linux-arm-kernel

Hi,

On Tue, Feb 08, 2022 at 09:41:39PM +0100, Julia Lawall wrote:
> From: kernel test robot <lkp@intel.com>
> 
> The code seems more readable with min.
> 
> Generated by: scripts/coccinelle/misc/minmax.cocci
> 
> Fixes: 2b9408d09dc6 ("remoteproc: Add support for peek from remote and acking kick from remote")
> CC: Wendy Liang <wendy.liang@xilinx.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
> 
> ---
> 
> tree:   https://github.com/Xilinx/linux-xlnx xlnx_rebase_v5.15
> head:   1183ce490adb103e5e569b8ebd74c50c885ddc05
> commit: 2b9408d09dc6367fd2f0820f0c7beab69e9aed56 [550/872] remoteproc: Add support for peek from remote and acking kick from remote
> :::::: branch date: 7 days ago
> :::::: commit date: 7 days ago
> 
>  remoteproc_sysfs.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/drivers/remoteproc/remoteproc_sysfs.c
> +++ b/drivers/remoteproc/remoteproc_sysfs.c
> @@ -241,7 +241,7 @@ static ssize_t kick_store(struct device
>  	size_t cpy_len;
> 
>  	(void)attr;
> -	cpy_len = count <= sizeof(id) ? count : sizeof(id);
> +	cpy_len = min(count, sizeof(id));

Looking at the min() macro the above would become "count < sizeof(id)" rather
than "count <= sizeof(id)".  I don't have more context into this code because I
can't find it in rproc-next nor today's linux-next, but it is something to look
into.  The patch is also missing the minmax.h include for the min() macro.

Thanks,
Mathieu

>  	memcpy((char *)(&id), buf, cpy_len);
> 
>  	if (rproc->ops->kick)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-02-10 18:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-08 20:41 [PATCH] remoteproc: fix minmax.cocci warnings Julia Lawall
2022-02-10 17:58 ` Mathieu Poirier

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