Skip to contentSkip to conversation

media: si2157: ensure wait_status is initialized

PATCH New Sean Young 1 participant 1 message Apr 22, 2020

Subsystems (2)
lore
Share & tools
lore

Sean Young

author
#0 lore raw

PATCH 1/1 media: si2157: ensure wait_status is initialized

smatch reports wait_status is uninitialized, because smatch cannot assume the loop body is ever executed.

Clarify the code so that wait_status is retrieved at least once.

---
 drivers/media/tuners/si2157.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/tuners/si2157.c +4 -1
index 6b452565dedb..088d96fdf8f6 100644
@@ -327,7 +327,7 @@ static int si2157_tune_wait(struct i2c_client *client, u8 is_digital)
 	/* wait tuner command complete */
 	start_time = jiffies;
 	timeout = start_time + msecs_to_jiffies(TUN_TIMEOUT);
-	while (!time_after(jiffies, timeout)) {
+	for (;;) {
 		ret = i2c_master_recv(client, &wait_status,
 				      sizeof(wait_status));
 		if (ret < 0) {
@@ -337,6 +337,9 @@ static int si2157_tune_wait(struct i2c_client *client, u8 is_digital)
 			goto err_mutex_unlock;
 		}
 
+		if (time_after(jiffies, timeout))
+			break;
+
 		/* tuner done? */
 		if ((wait_status & 0x81) == 0x81)
 			break;
Signature · 1 line
2.25.3