Skip to contentSkip to conversation

staging: sm750fb: remove unused variable 'tmp' in sw_i2c_wait

PATCH In review Eduard Zateev 2 participants 2 messages Sep 23

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

PATCH 1/1 staging: sm750fb: remove unused variable 'tmp' in sw_i2c_wait

The variable 'tmp' in sw_i2c_wait() is written but never read outside the loop, triggering a set-but-not-used warning with W=1. The loop itself is a fixed-count busy-wait with no side effects; remove the unused variable and keep the empty loop body.

---
 drivers/staging/sm750fb/ddk750_swi2c.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +3 -5
index e63f3b00ec4c..55623ad35be2 100644
@@ -92,12 +92,10 @@ static void sw_i2c_wait(void)
      * it's more reliable than counter loop ..
      * write 0x61 to 0x3ce and read from 0x3cf
      */
-	int i, tmp;
+	int i;
 
-	for (i = 0; i < 600; i++) {
-		tmp = i;
-		tmp += i;
-	}
+	for (i = 0; i < 600; i++)
+		;
 }
 
 /*
Signature · 1 line
2.55.0
#1 lore raw
Quoted 7 lines · Eduard Zateev

The variable 'tmp' in sw_i2c_wait() is written but never read outside the loop, triggering a set-but-not-used warning with W=1. The loop itself is a fixed-count busy-wait with no side effects; remove the unused variable and keep the empty loop body.

---

Search the archives to see if someone has sent a patch like this before.

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

Compilers often remove empty busy loops so that probably explains why they added the nonsense code.

We don't want to silence this warning because the code is legitimately bad and should trigger a warning. But until someone can test it, then it's impossible to fix.

regards,
dan carpenter