Changeset 3031 for lm-sensors/trunk/lib/access.c
- Timestamp:
- 07/15/05 10:57:43 (8 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/lib/access.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/lib/access.c
r2692 r3031 140 140 /* Look up the label which belongs to this chip. Note that chip should not 141 141 contain wildcard values! *result is newly allocated (free it yourself). 142 This function will return 0 on success, and <0 on failure. 143 Changed behaviour as of libsensors.so.1: now we actually take notice 144 of the logical class, as documented, but not done before! */ 142 This function will return 0 on success, and <0 on failure. 143 If no label exists for this feature, its name is returned itself. */ 145 144 int sensors_get_label(sensors_chip_name name, int feature, char **result) 146 145 { 147 146 const sensors_chip *chip; 148 147 const sensors_chip_feature *featureptr; 149 const sensors_chip_feature *alt_featureptr;150 148 int i; 151 149 … … 155 153 if (! (featureptr = sensors_lookup_feature_nr(name.prefix,feature))) 156 154 return -SENSORS_ERR_NO_ENTRY; 157 if (featureptr->logical_mapping == SENSORS_NO_MAPPING) 158 alt_featureptr = NULL; 159 else if (! (alt_featureptr = 160 sensors_lookup_feature_nr(name.prefix, 161 featureptr->logical_mapping))) 162 return -SENSORS_ERR_NO_ENTRY; 155 163 156 for (chip = NULL; (chip = sensors_for_all_config_chips(name,chip));) 164 157 for (i = 0; i < chip->labels_count; i++) … … 168 161 if (! (*result = strdup(chip->labels[i].value))) 169 162 sensors_fatal_error("sensors_get_label","Allocating label text"); 170 return 0; /* Exact match always overrules! */ 171 } else if (alt_featureptr && 172 !strcasecmp(alt_featureptr->name, chip->labels[i].name)) { 173 if (*result) 174 free(*result); 175 if (! (*result = strdup(chip->labels[i].value))) 176 sensors_fatal_error("sensors_get_label","Allocating label text"); 163 return 0; 177 164 } 165 166 /* No label, return the feature name instead */ 178 167 if (! (*result = strdup(featureptr->name))) 179 168 sensors_fatal_error("sensors_get_label","Allocating label text");
