From 38d1d82cec2da11ae72225951764e00356c64149 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 29 Aug 2007 14:00:47 +0000 Subject: [PATCH] Looking up a mapping can't fail if looking up the feature itself succeeded (or that would be a bug in the library code.) git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4729 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/access.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/access.c b/lib/access.c index 64b75c53..632909a0 100644 --- a/lib/access.c +++ b/lib/access.c @@ -231,11 +231,13 @@ int sensors_get_value(const sensors_chip_name *name, int feature, return -SENSORS_ERR_WILDCARDS; if (!(main_feature = sensors_lookup_feature_nr(name, feature))) return -SENSORS_ERR_NO_ENTRY; + if (main_feature->data.compute_mapping == SENSORS_NO_MAPPING) alt_feature = NULL; - else if (!(alt_feature = sensors_lookup_feature_nr(name, - main_feature->data.compute_mapping))) - return -SENSORS_ERR_NO_ENTRY; + else + alt_feature = sensors_lookup_feature_nr(name, + main_feature->data.compute_mapping); + if (!(main_feature->data.mode & SENSORS_MODE_R)) return -SENSORS_ERR_ACCESS_R; for (chip = NULL; @@ -276,11 +278,13 @@ int sensors_set_value(const sensors_chip_name *name, int feature, return -SENSORS_ERR_WILDCARDS; if (!(main_feature = sensors_lookup_feature_nr(name, feature))) return -SENSORS_ERR_NO_ENTRY; + if (main_feature->data.compute_mapping == SENSORS_NO_MAPPING) alt_feature = NULL; - else if (!(alt_feature = sensors_lookup_feature_nr(name, - main_feature->data.compute_mapping))) - return -SENSORS_ERR_NO_ENTRY; + else + alt_feature = sensors_lookup_feature_nr(name, + main_feature->data.compute_mapping); + if (!(main_feature->data.mode & SENSORS_MODE_W)) return -SENSORS_ERR_ACCESS_W; for (chip = NULL;