From e012d14d95344f4bd885f155d11eb603f64104bc Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 30 Sep 2007 17:56:19 +0000 Subject: [PATCH] sensors: Better handling of the fault flags. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4910 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/sensors/chips.c | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index 0b813022..2f9804cc 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ SVN sensors: Fix spurious critical temperature alarm Print error messages to stderr Make error messages more helpful and consistent + Better handling of the fault flags sensors-conf-convert: Add a short help text 3.0.0-rc1 (2007-09-25) diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index 7da51a81..0c9f8e99 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -147,10 +147,6 @@ static void print_chip_temp(const sensors_chip_name *name, print_label(label, label_size); free(label); - sf = sensors_get_subfeature(name, feature, - SENSORS_SUBFEATURE_TEMP_INPUT); - val = sf ? get_value(name, sf) : 0; - sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_TEMP_ALARM); alarm = sf && get_value(name, sf); @@ -230,9 +226,15 @@ static void print_chip_temp(const sensors_chip_name *name, if (sf && get_value(name, sf)) { printf(" FAULT "); } else { - if (fahrenheit) - val = deg_ctof(val); - printf("%+6.1f%s ", val, degstr); + sf = sensors_get_subfeature(name, feature, + SENSORS_SUBFEATURE_TEMP_INPUT); + if (sf) { + val = get_value(name, sf); + if (fahrenheit) + val = deg_ctof(val); + printf("%+6.1f%s ", val, degstr); + } else + printf(" N/A "); } print_temp_limits(limit1, limit2, s1, s2, alarm); @@ -350,7 +352,6 @@ static void print_chip_fan(const sensors_chip_name *name, { const sensors_subfeature *sf, *sfmin, *sfdiv; char *label; - double val; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", @@ -360,15 +361,18 @@ static void print_chip_fan(const sensors_chip_name *name, print_label(label, label_size); free(label); - sf = sensors_get_subfeature(name, feature, - SENSORS_SUBFEATURE_FAN_INPUT); - val = sf ? get_value(name, sf) : 0; sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_FAN_FAULT); if (sf && get_value(name, sf)) printf(" FAULT"); - else - printf("%4.0f RPM", val); + else { + sf = sensors_get_subfeature(name, feature, + SENSORS_SUBFEATURE_FAN_INPUT); + if (sf) + printf("%4.0f RPM", get_value(name, sf)); + else + printf(" N/A"); + } sfmin = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_FAN_MIN);