[PATCH] staging: sm750fb: remove unused variable 'tmp' in sw_i2c_wait

Eduard Zateev posted 1 patch 1 day, 12 hours ago
drivers/staging/sm750fb/ddk750_swi2c.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH] staging: sm750fb: remove unused variable 'tmp' in sw_i2c_wait
Posted by Eduard Zateev 1 day, 12 hours ago
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.

Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
---
 drivers/staging/sm750fb/ddk750_swi2c.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c
index e63f3b00ec4c..55623ad35be2 100644
--- a/drivers/staging/sm750fb/ddk750_swi2c.c
+++ b/drivers/staging/sm750fb/ddk750_swi2c.c
@@ -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++)
+		;
 }
 
 /*
-- 
2.55.0
Re: [PATCH] staging: sm750fb: remove unused variable 'tmp' in sw_i2c_wait
Posted by Dan Carpenter 1 day, 6 hours ago
On Wed, Sep 23, 2026 at 03:35:26AM +0200, Eduard Zateev wrote:
> 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.
> 
> Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
> ---

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

https://lore.kernel.org/all/abfFn_AET_xAVjji@stanley.mountain/

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