Skip to contentSkip to conversation

hwmon: (pmbus) Fix the logic of checking if no id is matched

PATCH Superseded Axel Lin 1 participant 1 message Aug 31, 2011 Hardware monitoring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 hwmon: (pmbus) Fix the logic of checking if no id is matched

If no id is matched, the mid pointer is not NULL in current implementation.

---
 drivers/hwmon/pmbus/ucd9000.c |    3 +--
 drivers/hwmon/pmbus/ucd9200.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/hwmon/pmbus/ucd9000.c +1 -2
index 285bb15..4aa8701 100644
@@ -141,13 +141,12 @@ static int ucd9000_probe(struct i2c_client *client,
 	block_buffer[ret] = '\0';
 	dev_info(&client->dev, "Device ID %s\n", block_buffer);
 
-	mid = NULL;
 	for (i = 0; i < ARRAY_SIZE(ucd9000_id); i++) {
 		mid = &ucd9000_id[i];
 		if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
 			break;
 	}
-	if (!mid || !strlen(mid->name)) {
+	if ((i = ARRAY_SIZE(ucd9000_id)) || !strlen(mid->name)) {
 		dev_err(&client->dev, "Unsupported device\n");
 		return -ENODEV;
 	}
drivers/hwmon/pmbus/ucd9200.c +1 -2
index 786f6cd..826cc8f 100644
@@ -68,13 +68,12 @@ static int ucd9200_probe(struct i2c_client *client,
 	block_buffer[ret] = '\0';
 	dev_info(&client->dev, "Device ID %s\n", block_buffer);
 
-	mid = NULL;
 	for (i = 0; i < ARRAY_SIZE(ucd9200_id); i++) {
 		mid = &ucd9200_id[i];
 		if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
 			break;
 	}
-	if (!mid || !strlen(mid->name)) {
+	if ((i = ARRAY_SIZE(ucd9200_id)) || !strlen(mid->name)) {
 		dev_err(&client->dev, "Unsupported device\n");
 		return -ENODEV;
 	}
Signature · 9 lines
1.7.4.1




_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors