summaryrefslogtreecommitdiff
path: root/lib/sysfs.c
diff options
context:
space:
mode:
authorkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2007-09-23 14:34:42 +0000
committerkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2007-09-23 14:34:42 +0000
commitcd894907ed0e26e1a075727f7cfa9b8047cb34e4 (patch)
treee0d36596b2620879c133e50693e8e4d86a12d5de /lib/sysfs.c
parent2b1ea6f681026d26ec3dffe380af1b77926308c5 (diff)
downloadlm-sensors-cd894907ed0e26e1a075727f7cfa9b8047cb34e4.tar.gz
Don't arbitrarily write errors to stderr. In production mode,
simply ignore the errors. In debug mode, call sensors_fatal_error(). As a side note, there is certainly room for improvement in the way errors are reported by libsensors. sensors_fatal_error() is fatal, and sensors_parse_error() is too specific, so we lack a more general error reporting function. printf-like formatting for error messages would also be a good idea. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4855 7894878c-1315-0410-8ee3-d5d059ff63e0
Diffstat (limited to 'lib/sysfs.c')
-rw-r--r--lib/sysfs.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c
index 2fe9d826..2a436576 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -213,15 +213,17 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
switch (sftype & 0xFF00) {
case SENSORS_SUBFEATURE_FAN_INPUT:
case SENSORS_SUBFEATURE_TEMP_INPUT:
- if (nr)
- nr--;
+ nr--;
break;
}
- if (nr >= MAX_SENSORS_PER_TYPE) {
- fprintf(stderr, "libsensors error, more sensors of one"
- " type then MAX_SENSORS_PER_TYPE, ignoring "
- "subfeature: %s\n", name);
+ if (nr < 0 || nr >= MAX_SENSORS_PER_TYPE) {
+ /* More sensors of one type than MAX_SENSORS_PER_TYPE,
+ we have to ignore it */
+#ifdef DEBUG
+ sensors_fatal_error(__FUNCTION__,
+ "Increase MAX_SENSORS_PER_TYPE!");
+#endif
continue;
}
@@ -243,9 +245,10 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
}
if (all_subfeatures[i].name) {
- fprintf(stderr, "libsensors error, trying to add dupli"
- "cate subfeature: %s to dynamic feature table\n",
- name);
+#ifdef DEBUG
+ sensors_fatal_error(__FUNCTION__,
+ "Duplicate subfeature");
+#endif
continue;
}