Let libsensors handle ignore statements by itself, rather than

delegating the task to the user applications.

For now, I am calling sensors_get_ignored() in
sensors_get_all_features(), because this is the least intrusive way.
This is in no way optimal though, it would be better to not add
ignored features to the feature list in the first place. However,
doing so would require that the configuration file is read before
sysfs is scanned for features, which isn't currently the case. So
this improvement is left for later.

Note that this patch adds a small cost in terms of performance. This
is because we now honor ignore statements on all features (main ones
and subfeatures) while in practice "sensors" was only checking for
main features. It would be trivial to stop checking for subfeatures,
but it seems to me that supporting ignore on subfeatures is a good
move, as the user may actually want to ignore a specific subfeature.
Individual alarms come to mind. This will also be handy to debug the
generic print code in "sensors".


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4644 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2007-07-24 08:20:53 +00:00
1 parent 6505fef0fd
commit e9c8c5fb06
3 files changed
+8 -12

No files matched your search

+7 -1
View File
@@ -193,7 +193,10 @@ sensors_get_label_exit:
return 0;
}
int sensors_get_ignored(sensors_chip_name name, int feature)
/* Looks up whether a feature should be ignored. Returns <0 on failure,
0 if it should be ignored, 1 if it is valid. This function takes
logical mappings into account. */
static int sensors_get_ignored(sensors_chip_name name, int feature)
{
const sensors_chip *chip;
const sensors_chip_feature *featureptr;
@@ -343,6 +346,9 @@ const sensors_feature_data *sensors_get_all_features(sensors_chip_name name,
for (i = 0; i < sensors_proc_chips_count; i++)
if (sensors_match_chip(sensors_proc_chips[i].chip, name)) {
feature_list = sensors_proc_chips[i].feature;
while (feature_list[*nr].data.name
&& sensors_get_ignored(name, feature_list[*nr].data.number) != 1)
(*nr)++;
if (!feature_list[*nr].data.name)
return NULL;
return &feature_list[(*nr)++].data;
-5
View File
@@ -83,11 +83,6 @@ extern const char *sensors_get_adapter_name(int bus_nr);
extern int sensors_get_label(sensors_chip_name name, int feature,
char **result);
/* Looks up whether a feature should be ignored. Returns <0 on failure,
0 if it should be ignored, 1 if it is valid. This function takes
logical mappings into account. */
extern int sensors_get_ignored(sensors_chip_name name, int fature);
/* Read the value of a feature of a certain chip. Note that chip should not
contain wildcard values! This function will return 0 on success, and <0
on failure. */
+1 -6
View File
@@ -91,12 +91,7 @@ int sensors_get_label_and_valid(sensors_chip_name name, int feature, char **labe
{
int err;
err = sensors_get_label(name,feature,label);
if (!err)
err = sensors_get_ignored(name,feature);
if (err >= 0) {
*valid = err;
err = 0;
}
*valid = !err;
return err;
}