Skip to contentSkip to conversation

ipmi_ssif: silence an uninitialized variable warning

PATCH In review Dan Carpenter 2 participants 2 messages Apr 4, 2016

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

PATCH 1/1 ipmi_ssif: silence an uninitialized variable warning

My static checker complains that "ret" could be zero here. (Presumably that means the hardware is badly busted). But the result would be that the caller assumes *resp_len is initialized when it's not and it leads to a warning. Let's just silence the warning.

drivers/char/ipmi/ipmi_ssif.c +2 -0
index 8b3be8b..512c5b6 100644
@@ -1232,6 +1232,8 @@ static int do_cmd(struct i2c_client *client, int len, unsigned char *msg,
 			break;
 	}
 
+	if (ret = 0)
+		ret = -EINVAL;
 	if (ret > 0) {
 		/* Validate that the response is correct. */
 		if (ret < 3 ||
#1 lore raw
Quoted 4 lines · Dan Carpenter

My static checker complains that "ret" could be zero here. (Presumably that means the hardware is badly busted). But the result would be that the caller assumes *resp_len is initialized when it's not and it leads to a warning. Let's just silence the warning.

I don't think i2c_smbus_read_block_data() can return a zero, it's either an error or a message.

I'm ok with this, but can you add a comment saying why this is here? I don't like strange looking code without explanations.

Thanks,
-corey

Quoted 15 lines
drivers/char/ipmi/ipmi_ssif.c +2 -0
index 8b3be8b..512c5b6 100644
@@ -1232,6 +1232,8 @@ static int do_cmd(struct i2c_client *client, int len, unsigned char *msg,
  			break;
  	}
 
+	if (ret = 0)
+		ret = -EINVAL;
  	if (ret > 0) {
  		/* Validate that the response is correct. */
  		if (ret < 3 ||