From 55e467b151511921c1559309b9701720e311fefa Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 23 Sep 2007 14:34:42 +0000 Subject: [PATCH] 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 --- lib/sysfs.c | 21 ++++++++++++--------- 1 file 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; }