Skip to contentSkip to conversation

stm class: Remove unnecessary local variable in stm_write

PATCH RESEND Superseded Thorsten Blum 2 participants 3 messages Jan 26

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 stm class: Remove unnecessary local variable in stm_write

The local variable 'err' and the corresponding if check in stm_write() are unnecessary. Remove them.

---
 drivers/hwtracing/stm/core.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/hwtracing/stm/core.c +1 -7
index cdba4e875b28..f3814e4ecf23 100644
@@ -602,17 +602,11 @@ static ssize_t notrace
 stm_write(struct stm_device *stm, struct stm_output *output,
 	  unsigned int chan, const char *buf, size_t count, struct stm_source_data *source)
 {
-	int err;
-
 	/* stm->pdrv is serialized against policy_mutex */
 	if (!stm->pdrv)
 		return -ENODEV;
 
-	err = stm->pdrv->write(stm->data, output, chan, buf, count, source);
-	if (err < 0)
-		return err;
-
-	return err;
+	return stm->pdrv->write(stm->data, output, chan, buf, count, source);
 }
 
 static ssize_t stm_char_write(struct file *file, const char __user *buf,
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
#1 lore raw
Quoted 2 lines · Thorsten Blum

The local variable 'err' and the corresponding if check in stm_write() are unnecessary. Remove them.

Nice catch! Is this a result of manual code inspection or were any tools used, an AI agent or a coccinelle script or whatnot?

Thanks,
--
Alex

#2 lore raw
Quoted 7 lines · Alexander Shishkin
Quoted 2 lines · Thorsten Blum

The local variable 'err' and the corresponding if check in stm_write() are unnecessary. Remove them.

Nice catch! Is this a result of manual code inspection or were any tools used, an AI agent or a coccinelle script or whatnot?

Manual code inspection. I think I stumbled upon it when I was working on

https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

which are also still pending. Could you take a look at all three patches while you're at it?

Thanks,
Thorsten