Skip to contentSkip to conversation

remoteproc: fix minmax.cocci warnings

PATCH In review Julia Lawall 2 participants 2 messages Feb 8, 2022 – Feb 10, 2022 Remote processor (remoteproc)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remoteproc: fix minmax.cocci warnings

From: kernel test robot <[email protected]>

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 <[email protected]>

---

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(-)
drivers/remoteproc/remoteproc_sysfs.c +1 -1
@@ -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)
maintainer
#1 lore raw

Hi,

Quoted 26 lines · Julia Lawall

From: kernel test robot <[email protected]>

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 <[email protected]>

---

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

drivers/remoteproc/remoteproc_sysfs.c static ssize_t kick_store(struct device · line 244

Quoted 5 lines
drivers/remoteproc/remoteproc_sysfs.c +1 -1
@@ -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

Quoted 3 lines
drivers/remoteproc/remoteproc_sysfs.c +0 -0
 	memcpy((char *)(&id), buf, cpy_len);
 
 	if (rproc->ops->kick)