Changeset 105

Show
Ignore:
Timestamp:
12/23/98 02:05:45 (15 years ago)
Author:
frodo
Message:

Corrected sensors_get_feature expression search

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/lib/access.c

    r104 r105  
    155155int sensors_get_feature(sensors_chip_name name, int feature, double *result) 
    156156{ 
    157   sensors_chip_feature *featureptr; 
     157  sensors_chip_feature *main_feature; 
     158  sensors_chip_feature *alt_feature; 
    158159  sensors_chip *chip; 
    159160  sensors_expr *expr = NULL; 
    160161  double val; 
    161162  int res,i; 
     163  int final_expr=0; 
    162164 
    163165  if (sensors_chip_name_has_wildcards(name)) 
    164166    return -SENSORS_ERR_WILDCARDS; 
    165   if (! (featureptr = sensors_lookup_feature_nr(name.prefix,feature))) 
    166     return -SENSORS_ERR_NO_ENTRY; 
    167   if (! (featureptr->mode && SENSORS_R)) 
     167  if (! (main_feature = sensors_lookup_feature_nr(name.prefix,feature))) 
     168    return -SENSORS_ERR_NO_ENTRY; 
     169  if (main_feature->compute_mapping == SENSORS_NO_MAPPING) 
     170    alt_feature = NULL; 
     171  else if (! (alt_feature = 
     172                   sensors_lookup_feature_nr(name.prefix, 
     173                                             main_feature->compute_mapping))) 
     174    return -SENSORS_ERR_NO_ENTRY; 
     175  if (! (main_feature->mode && SENSORS_R)) 
    168176    return -SENSORS_ERR_ACCESS; 
    169177  for (chip = NULL; !expr && (chip = sensors_for_all_config_chips(name,chip));) 
    170     for (i = 0; !expr && (i < chip->computes_count); i++) 
    171       if (!strcmp(featureptr->name,chip->computes->name)) 
    172         expr = chip->computes->from_proc; 
     178    for (i = 0; !final_expr && (i < chip->computes_count); i++) { 
     179      if (!strcmp(main_feature->name,chip->computes[i].name)) { 
     180        expr = chip->computes[i].from_proc; 
     181        final_expr = 1; 
     182      } else if (alt_feature &&  
     183                 !strcmp(alt_feature->name,chip->computes[i].name)) 
     184        expr = chip->computes[i].from_proc; 
     185    } 
    173186  if (sensors_read_proc(name,feature,&val)) 
    174187    return -SENSORS_ERR_PROC;