Changeset 4550
- Timestamp:
- 07/04/07 09:54:37 (6 years ago)
- Files:
-
- 1 modified
-
lm-sensors/branches/lm-sensors-3.0.0/lib/access.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/lib/access.c
r4545 r4550 152 152 const sensors_chip *chip; 153 153 const sensors_chip_feature *featureptr; 154 char buf[128], path[PATH_MAX]; 155 FILE *f; 154 156 int i; 155 157 … … 163 165 for (i = 0; i < chip->labels_count; i++) 164 166 if (!strcasecmp(featureptr->data.name,chip->labels[i].name)){ 165 if (*result) 166 free(*result); 167 if (!(*result = strdup(chip->labels[i].value))) 168 sensors_fatal_error("sensors_get_label", 169 "Allocating label text"); 170 return 0; 167 *result = strdup(chip->labels[i].value); 168 goto sensors_get_label_exit; 171 169 } 172 170 171 /* No user specified label, check for a _label sysfs file */ 172 snprintf(path, PATH_MAX, "%s/%s_label", name.busname, 173 featureptr->data.name); 174 175 if ((f = fopen(path, "r"))) { 176 i = fread(buf, 1, sizeof(buf) - 1, f); 177 fclose(f); 178 if (i > 0) { 179 /* i - 1 to strip the '\n' at the end */ 180 buf[i - 1] = 0; 181 *result = strdup(buf); 182 goto sensors_get_label_exit; 183 } 184 } 185 173 186 /* No label, return the feature name instead */ 174 if (!(*result = strdup(featureptr->data.name))) 187 *result = strdup(featureptr->data.name); 188 189 sensors_get_label_exit: 190 if (*result == NULL) 175 191 sensors_fatal_error("sensors_get_label", 176 192 "Allocating label text");
