Skip to contentSkip to conversation

libsensors4: Fix corner case bug in

PATCH In review Jean Delvare 2 participants 2 messages Aug 17, 2007 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 libsensors4: Fix corner case bug in

Contrary to what the comment says, sensors_proc_bus_count may be a perfectly valid bus number. We need to use a different value for chip configuration entries we want to ignore.

---
 lib/data.c    |    8 ++++----
 lib/sensors.h |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
lib/data.c +4 -4
@@ -192,7 +192,7 @@ int sensors_substitute_chip(sensors_chip
 
 	if (i = sensors_config_busses_count) {
 		sensors_parse_error("Undeclared bus id referenced", lineno);
-		name->bus.nr = sensors_proc_bus_count;
+		name->bus.nr = SENSORS_BUS_NR_IGNORE;
 		return -SENSORS_ERR_BUS_NAME;
 	}
 
@@ -205,9 +205,9 @@ int sensors_substitute_chip(sensors_chip
 		}
 	}
 
-	/* We did not find anything. sensors_proc_bus_count is not
-	   a valid bus number, so it will never be matched. Good. */
-	name->bus.nr = sensors_proc_bus_count;
+	/* We did not find a matching bus name, simply ignore this chip
+	   config entry. */
+	name->bus.nr = SENSORS_BUS_NR_IGNORE;
 	return 0;
 }
 
lib/sensors.h +1 -0
@@ -34,6 +34,7 @@
 #define SENSORS_BUS_TYPE_ISA	1
 #define SENSORS_BUS_TYPE_PCI	2
 #define SENSORS_BUS_NR_ANY	(-1)
+#define SENSORS_BUS_NR_IGNORE	(-2)
 
 #ifdef __cplusplus
 extern "C" {
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 4 lines · Jean Delvare

Contrary to what the comment says, sensors_proc_bus_count may be a perfectly valid bus number. We need to use a different value for chip configuration entries we want to ignore.

Looks good to me, can you commit these to svn before the end of the weekend, monday I'll be back at work and there I have several machines to test with, so if you can get all your changes into svn before monday then I can give svn a good testing with various setups @ work.

Regards,

Hans

Quoted 34 lines
---
 lib/data.c    |    8 ++++----
 lib/sensors.h |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
lib/data.c +4 -4
@@ -192,7 +192,7 @@ int sensors_substitute_chip(sensors_chip
 
 	if (i = sensors_config_busses_count) {
 		sensors_parse_error("Undeclared bus id referenced", lineno);
-		name->bus.nr = sensors_proc_bus_count;
+		name->bus.nr = SENSORS_BUS_NR_IGNORE;
 		return -SENSORS_ERR_BUS_NAME;
 	}
 
@@ -205,9 +205,9 @@ int sensors_substitute_chip(sensors_chip
 		}
 	}
 
-	/* We did not find anything. sensors_proc_bus_count is not
-	   a valid bus number, so it will never be matched. Good. */
-	name->bus.nr = sensors_proc_bus_count;
+	/* We did not find a matching bus name, simply ignore this chip
+	   config entry. */
+	name->bus.nr = SENSORS_BUS_NR_IGNORE;
 	return 0;
 }
 

lib/sensors.h line 40

Quoted 7 lines
lib/sensors.h +1 -0
@@ -34,6 +34,7 @@
 #define SENSORS_BUS_TYPE_ISA	1
 #define SENSORS_BUS_TYPE_PCI	2
 #define SENSORS_BUS_NR_ANY	(-1)
+#define SENSORS_BUS_NR_IGNORE	(-2)
 
 #ifdef __cplusplus
 extern "C" {

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