diff --git a/CHANGES b/CHANGES index 7f7715ff..1f96ce99 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ SVN HEAD Speed up sensors_get_ignored() a bit No longer export sensors_chip_name_has_wildcards() Delete sensors_do_all_sets(), unused + Pass structures by reference Makefile: Drop the package and version targets Man page sensors.conf.5: Update the chip statement section Programs doc/*: Delete, obsolete diff --git a/lib/access.c b/lib/access.c index 99c323f4..59603af9 100644 --- a/lib/access.c +++ b/lib/access.c @@ -33,33 +33,34 @@ static int sensors_eval_expr(sensors_chip_name chipname, /* Compare two chips name descriptions, to see whether they could match. Return 0 if it does not match, return 1 if it does match. */ -int sensors_match_chip(sensors_chip_name chip1, sensors_chip_name chip2) +int sensors_match_chip(const sensors_chip_name *chip1, + const sensors_chip_name *chip2) { - if ((chip1.prefix != SENSORS_CHIP_NAME_PREFIX_ANY) && - (chip2.prefix != SENSORS_CHIP_NAME_PREFIX_ANY) && - strcasecmp(chip1.prefix, chip2.prefix)) + if ((chip1->prefix != SENSORS_CHIP_NAME_PREFIX_ANY) && + (chip2->prefix != SENSORS_CHIP_NAME_PREFIX_ANY) && + strcasecmp(chip1->prefix, chip2->prefix)) return 0; - if ((chip1.bus != SENSORS_CHIP_NAME_BUS_ANY) && - (chip2.bus != SENSORS_CHIP_NAME_BUS_ANY) && - (chip1.bus != chip2.bus)) { + if ((chip1->bus != SENSORS_CHIP_NAME_BUS_ANY) && + (chip2->bus != SENSORS_CHIP_NAME_BUS_ANY) && + (chip1->bus != chip2->bus)) { - if ((chip1.bus == SENSORS_CHIP_NAME_BUS_ISA) || - (chip2.bus == SENSORS_CHIP_NAME_BUS_ISA)) + if ((chip1->bus == SENSORS_CHIP_NAME_BUS_ISA) || + (chip2->bus == SENSORS_CHIP_NAME_BUS_ISA)) return 0; - if ((chip1.bus == SENSORS_CHIP_NAME_BUS_PCI) || - (chip2.bus == SENSORS_CHIP_NAME_BUS_PCI)) + if ((chip1->bus == SENSORS_CHIP_NAME_BUS_PCI) || + (chip2->bus == SENSORS_CHIP_NAME_BUS_PCI)) return 0; - if ((chip1.bus != SENSORS_CHIP_NAME_BUS_ANY_I2C) && - (chip2.bus != SENSORS_CHIP_NAME_BUS_ANY_I2C)) + if ((chip1->bus != SENSORS_CHIP_NAME_BUS_ANY_I2C) && + (chip2->bus != SENSORS_CHIP_NAME_BUS_ANY_I2C)) return 0; } - if ((chip1.addr != chip2.addr) && - (chip1.addr != SENSORS_CHIP_NAME_ADDR_ANY) && - (chip2.addr != SENSORS_CHIP_NAME_ADDR_ANY)) + if ((chip1->addr != chip2->addr) && + (chip1->addr != SENSORS_CHIP_NAME_ADDR_ANY) && + (chip2->addr != SENSORS_CHIP_NAME_ADDR_ANY)) return 0; return 1; @@ -84,7 +85,7 @@ sensors_for_all_config_chips(sensors_chip_name chip_name, chips = sensors_config_chips[nr].chips; for (i = 0; i < chips.fits_count; i++) { - if (sensors_match_chip(chips.fits[i], chip_name)) + if (sensors_match_chip(&chips.fits[i], &chip_name)) return sensors_config_chips + nr; } } @@ -101,7 +102,7 @@ const sensors_chip_feature *sensors_lookup_feature_nr(const sensors_chip_name *c const sensors_chip_feature *features; for (i = 0; i < sensors_proc_chips_count; i++) - if (sensors_match_chip(sensors_proc_chips[i].chip, *chip)) { + if (sensors_match_chip(&sensors_proc_chips[i].chip, chip)) { features = sensors_proc_chips[i].feature; for (j = 0; features[j].data.name; j++) if (features[j].data.number == feature) @@ -120,7 +121,7 @@ sensors_lookup_feature_name(const sensors_chip_name *chip, const char *feature) const sensors_chip_feature *features; for (i = 0; i < sensors_proc_chips_count; i++) - if (sensors_match_chip(sensors_proc_chips[i].chip, *chip)) { + if (sensors_match_chip(&sensors_proc_chips[i].chip, chip)) { features = sensors_proc_chips[i].feature; for (j = 0; features[j].data.name; j++) if (!strcasecmp(features[j].data.name, feature)) @@ -147,7 +148,7 @@ static int sensors_chip_name_has_wildcards(sensors_chip_name chip) contain wildcard values! *result is newly allocated (free it yourself). This function will return 0 on success, and <0 on failure. If no label exists for this feature, its name is returned itself. */ -int sensors_get_label(sensors_chip_name name, int feature, char **result) +int sensors_get_label(const sensors_chip_name *name, int feature, char **result) { const sensors_chip *chip; const sensors_chip_feature *featureptr; @@ -156,12 +157,12 @@ int sensors_get_label(sensors_chip_name name, int feature, char **result) int i; *result = NULL; - if (sensors_chip_name_has_wildcards(name)) + if (sensors_chip_name_has_wildcards(*name)) return -SENSORS_ERR_WILDCARDS; - if (!(featureptr = sensors_lookup_feature_nr(&name, feature))) + if (!(featureptr = sensors_lookup_feature_nr(name, feature))) return -SENSORS_ERR_NO_ENTRY; - for (chip = NULL; (chip = sensors_for_all_config_chips(name, chip));) + for (chip = NULL; (chip = sensors_for_all_config_chips(*name, chip));) for (i = 0; i < chip->labels_count; i++) if (!strcasecmp(featureptr->data.name,chip->labels[i].name)){ *result = strdup(chip->labels[i].value); @@ -169,7 +170,7 @@ int sensors_get_label(sensors_chip_name name, int feature, char **result) } /* No user specified label, check for a _label sysfs file */ - snprintf(path, PATH_MAX, "%s/%s_label", name.busname, + snprintf(path, PATH_MAX, "%s/%s_label", name->busname, featureptr->data.name); if ((f = fopen(path, "r"))) { @@ -221,7 +222,8 @@ static int sensors_get_ignored(const sensors_chip_name *name, /* 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. */ -int sensors_get_feature(sensors_chip_name name, int feature, double *result) +int sensors_get_feature(const sensors_chip_name *name, int feature, + double *result) { const sensors_chip_feature *main_feature; const sensors_chip_feature *alt_feature; @@ -231,19 +233,19 @@ int sensors_get_feature(sensors_chip_name name, int feature, double *result) int res, i; int final_expr = 0; - if (sensors_chip_name_has_wildcards(name)) + if (sensors_chip_name_has_wildcards(*name)) return -SENSORS_ERR_WILDCARDS; - if (!(main_feature = sensors_lookup_feature_nr(&name, feature))) + 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, + else if (!(alt_feature = sensors_lookup_feature_nr(name, main_feature->data.compute_mapping))) return -SENSORS_ERR_NO_ENTRY; if (!(main_feature->data.mode & SENSORS_MODE_R)) return -SENSORS_ERR_ACCESS_R; for (chip = NULL; - !expr && (chip = sensors_for_all_config_chips(name, chip));) + !expr && (chip = sensors_for_all_config_chips(*name, chip));) for (i = 0; !final_expr && (i < chip->computes_count); i++) { if (!strcasecmp(main_feature->data.name, chip->computes[i].name)) { expr = chip->computes[i].from_proc; @@ -253,11 +255,11 @@ int sensors_get_feature(sensors_chip_name name, int feature, double *result) expr = chip->computes[i].from_proc; } } - if (sensors_read_sysfs_attr(name, feature, &val)) + if (sensors_read_sysfs_attr(*name, feature, &val)) return -SENSORS_ERR_PROC; if (!expr) *result = val; - else if ((res = sensors_eval_expr(name, expr, val, result))) + else if ((res = sensors_eval_expr(*name, expr, val, result))) return res; return 0; } @@ -265,7 +267,8 @@ int sensors_get_feature(sensors_chip_name name, int feature, double *result) /* Set 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. */ -int sensors_set_feature(sensors_chip_name name, int feature, double value) +int sensors_set_feature(const sensors_chip_name *name, int feature, + double value) { const sensors_chip_feature *main_feature; const sensors_chip_feature *alt_feature; @@ -275,19 +278,19 @@ int sensors_set_feature(sensors_chip_name name, int feature, double value) int final_expr = 0; double to_write; - if (sensors_chip_name_has_wildcards(name)) + if (sensors_chip_name_has_wildcards(*name)) return -SENSORS_ERR_WILDCARDS; - if (!(main_feature = sensors_lookup_feature_nr(&name, feature))) + 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, + else if (!(alt_feature = sensors_lookup_feature_nr(name, main_feature->data.compute_mapping))) return -SENSORS_ERR_NO_ENTRY; if (!(main_feature->data.mode & SENSORS_MODE_W)) return -SENSORS_ERR_ACCESS_W; for (chip = NULL; - !expr && (chip = sensors_for_all_config_chips(name, chip));) + !expr && (chip = sensors_for_all_config_chips(*name, chip));) for (i = 0; !final_expr && (i < chip->computes_count); i++) if (!strcasecmp(main_feature->data.name, chip->computes[i].name)) { expr = chip->computes->to_proc; @@ -299,9 +302,9 @@ int sensors_set_feature(sensors_chip_name name, int feature, double value) to_write = value; if (expr) - if ((res = sensors_eval_expr(name, expr, value, &to_write))) + if ((res = sensors_eval_expr(*name, expr, value, &to_write))) return res; - if (sensors_write_sysfs_attr(name, feature, to_write)) + if (sensors_write_sysfs_attr(*name, feature, to_write)) return -SENSORS_ERR_PROC; return 0; } @@ -332,17 +335,17 @@ const char *sensors_get_adapter_name(int bus_nr) } /* nr-1 is the last feature returned */ -const sensors_feature_data *sensors_get_all_features(sensors_chip_name name, +const sensors_feature_data *sensors_get_all_features(const sensors_chip_name *name, int *nr) { sensors_chip_feature *feature_list; int i; for (i = 0; i < sensors_proc_chips_count; i++) - if (sensors_match_chip(sensors_proc_chips[i].chip, name)) { + 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])) + && sensors_get_ignored(name, &feature_list[*nr])) (*nr)++; if (!feature_list[*nr].data.name) return NULL; @@ -371,7 +374,7 @@ int sensors_eval_expr(sensors_chip_name chipname, const sensors_expr * expr, if (!(feature = sensors_lookup_feature_name(&chipname, expr->data.var))) return SENSORS_ERR_NO_ENTRY; - if (!(res = sensors_get_feature(chipname, feature->data.number, result))) + if (!(res = sensors_get_feature(&chipname, feature->data.number, result))) return res; return 0; } @@ -455,7 +458,7 @@ static int sensors_do_this_chip_sets(sensors_chip_name name) err = res; continue; } - if ((res = sensors_set_feature(name, feature_nr, value))) { + if ((res = sensors_set_feature(&name, feature_nr, value))) { sensors_parse_error("Failed to set feature", chip->sets[i].lineno); err = res; @@ -468,14 +471,14 @@ static int sensors_do_this_chip_sets(sensors_chip_name name) /* Execute all set statements for this particular chip. The chip may contain wildcards! This function will return 0 on success, and <0 on failure. */ -int sensors_do_chip_sets(sensors_chip_name name) +int sensors_do_chip_sets(const sensors_chip_name *name) { int nr, this_res; const sensors_chip_name *found_name; int res = 0; for (nr = 0; (found_name = sensors_get_detected_chips(&nr));) - if (sensors_match_chip(name, *found_name)) { + if (sensors_match_chip(name, found_name)) { this_res = sensors_do_this_chip_sets(*found_name); if (!res) res = this_res; diff --git a/lib/libsensors.3 b/lib/libsensors.3 index 13b14d8c..db176fc5 100644 --- a/lib/libsensors.3 +++ b/lib/libsensors.3 @@ -35,19 +35,19 @@ libsensors \- publicly accessible functions provided by the sensors library .B void sensors_cleanup(void); .B int sensors_parse_chip_name(const char *orig_name, \fBsensors_chip_name *res);\fP -.B int sensors_match_chip(sensors_chip_name chip1, - \fBsensors_chip_name chip2);\fP +.B int sensors_match_chip(const sensors_chip_name *chip1, + \fBconst sensors_chip_name *chip2);\fP .B const char *sensors_get_adapter_name(int bus_nr); -.B int sensors_get_label(sensors_chip_name name, int feature, +.B int sensors_get_label(const sensors_chip_name *name, int feature, \fBchar **result);\fP -.B int sensors_get_feature(sensors_chip_name name, int feature, +.B int sensors_get_feature(const sensors_chip_name *name, int feature, \fBdouble *result);\fP -.B int sensors_set_feature(sensors_chip_name name, int feature, +.B int sensors_set_feature(const sensors_chip_name *name, int feature, \fBdouble value);\fP -.B int sensors_do_chip_sets(sensors_chip_name name); +.B int sensors_do_chip_sets(const sensors_chip_name *name); .B const sensors_chip_name *sensors_get_detected_chips(int *nr); .B const sensors_feature_data *sensors_get_all_features - \fB(sensors_chip_name name, int *nr);\fP + \fB(const sensors_chip_name *name, int *nr);\fP .B const char *libsensors_version; .fi .SH DESCRIPTION @@ -65,8 +65,8 @@ Clean-up function: You can't access anything after this, until the next sensors_ .br Parse a chip name to the internal representation. Return 0 on succes, <0 on error. -\fBint sensors_match_chip(sensors_chip_name chip1, - sensors_chip_name chip2);\fP +\fBint sensors_match_chip(const sensors_chip_name *chip1, + const sensors_chip_name *chip2);\fP .br Compare two chips name descriptions, to see whether they could match. Return 0 if it does not match, return 1 if it does match. @@ -75,22 +75,22 @@ Compare two chips name descriptions, to see whether they could match. Return 0 i This function returns the adapter name of a bus number, as used within the sensors_chip_name structure. If it could not be found, it returns NULL. -\fBint sensors_get_label(sensors_chip_name name, int feature, +\fBint sensors_get_label(const sensors_chip_name *name, int feature, char **result);\fP .br Look up the label which belongs to this chip. Note that chip should not contain wildcard values! *result is newly allocated (free it yourself). This function will return 0 on success, and <0 on failure. -\fBint sensors_get_feature(sensors_chip_name name, +\fBint sensors_get_feature(const sensors_chip_name *name, int feature, double *result);\fP .br 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. -\fBint sensors_set_feature(sensors_chip_name name, +\fBint sensors_set_feature(const sensors_chip_name *name, int feature, double value);\fP .br Set 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. -.B int sensors_do_chip_sets(sensors_chip_name name); +.B int sensors_do_chip_sets(const sensors_chip_name *name); .br Execute all set statements for this particular chip. The chip may contain wildcards! This function will return 0 on success, and <0 on failure. @@ -122,7 +122,7 @@ The mode field can be one of: SENSORS_MODE_NO_RW, SENSORS_MODE_R, SENSORS_MODE_W or SENSORS_MODE_RW. \fBconst sensors_feature_data *sensors_get_all_features - (sensors_chip_name name, int *nr);\fP + (const sensors_chip_name *name, int *nr);\fP .br This returns all features of a specific chip. They are returned in bunches: everything with the same mapping is returned just after each other, with diff --git a/lib/sensors.h b/lib/sensors.h index 53b2d5af..966b9d62 100644 --- a/lib/sensors.h +++ b/lib/sensors.h @@ -63,8 +63,8 @@ extern int sensors_parse_chip_name(const char *orig_name, /* Compare two chips name descriptions, to see whether they could match. Return 0 if it does not match, return 1 if it does match. */ -extern int sensors_match_chip(sensors_chip_name chip1, - sensors_chip_name chip2); +extern int sensors_match_chip(const sensors_chip_name *chip1, + const sensors_chip_name *chip2); /* This function returns the adapter name of a bus number, as used within the sensors_chip_name structure. If it could not be found, @@ -75,24 +75,24 @@ extern const char *sensors_get_adapter_name(int bus_nr); contain wildcard values! *result is newly allocated (free it yourself). This function will return 0 on success, and <0 on failure. This function takes logical mappings into account. */ -extern int sensors_get_label(sensors_chip_name name, int feature, +extern int sensors_get_label(const sensors_chip_name *name, int feature, char **result); /* 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. */ -extern int sensors_get_feature(sensors_chip_name name, int feature, +extern int sensors_get_feature(const sensors_chip_name *name, int feature, double *result); /* Set 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. */ -extern int sensors_set_feature(sensors_chip_name name, int feature, +extern int sensors_set_feature(const sensors_chip_name *name, int feature, double value); /* Execute all set statements for this particular chip. The chip may contain wildcards! This function will return 0 on success, and <0 on failure. */ -extern int sensors_do_chip_sets(sensors_chip_name name); +extern int sensors_do_chip_sets(const sensors_chip_name *name); /* This function returns all detected chips, one by one. To start at the beginning of the list, use 0 for nr; NULL is returned if we are @@ -171,7 +171,7 @@ typedef struct sensors_feature_data { Do not try to change the returned structure; you will corrupt internal data structures. */ extern const sensors_feature_data *sensors_get_all_features - (sensors_chip_name name, int *nr); + (const sensors_chip_name *name, int *nr); #ifdef __cplusplus } diff --git a/prog/sensord/rrd.c b/prog/sensord/rrd.c index bfbf4fa2..e44d52b2 100644 --- a/prog/sensord/rrd.c +++ b/prog/sensord/rrd.c @@ -141,7 +141,7 @@ applyToFeatures while ((ret == 0) && ((chip = sensors_get_detected_chips (&i)) != NULL)) { for (j = 0; (ret == 0) && (j < numChipNames); ++ j) { - if (sensors_match_chip (*chip, chipNames[j])) { + if (sensors_match_chip (chip, &chipNames[j])) { int index0, subindex, chipindex = -1; for (index0 = 0; knownChips[index0]; ++ index0) for (subindex = 0; knownChips[index0]->names[subindex]; ++ subindex) diff --git a/prog/sensord/sense.c b/prog/sensord/sense.c index 49058e39..67867a59 100644 --- a/prog/sensord/sense.c +++ b/prog/sensord/sense.c @@ -49,7 +49,7 @@ int getLabel (sensors_chip_name name, int feature, char **label) { int err; - err = sensors_get_label (name, feature, label); + err = sensors_get_label (&name, feature, label); return err; } @@ -59,7 +59,7 @@ getRawLabel const sensors_feature_data *rawFeature; int nr1 = 0, nr2 = 0, err = 0; do { - rawFeature = sensors_get_all_features (name, &nr1, &nr2); + rawFeature = sensors_get_all_features (&name, &nr1, &nr2); } while (rawFeature && (rawFeature->number != feature)); /* TODO: Ensure labels match RRD construct and are not repeated! */ if (!rawFeature) { @@ -105,7 +105,7 @@ readUnknownChip ret = idChip (chip); - while ((ret == 0) && ((sensor = sensors_get_all_features (*chip, &index0, &index1)) != NULL)) { + while ((ret == 0) && ((sensor = sensors_get_all_features (chip, &index0, &index1)) != NULL)) { char *label = NULL; int valid = 0; double value; @@ -120,7 +120,7 @@ readUnknownChip /* skip invalid */ } else if (!(sensor->mode & SENSORS_MODE_R)) { sensorLog (LOG_INFO, "%s: %s", sensor->name, label); - } else if ((ret = sensors_get_feature (*chip, sensor->number, &value))) { + } else if ((ret = sensors_get_feature (chip, sensor->number, &value))) { sensorLog (LOG_ERR, "Error getting sensor data: %s/%s: %s", chip->prefix, sensor->name, sensors_strerror (ret)); ret = 22; } else { @@ -145,7 +145,7 @@ doKnownChip if (action == DO_READ) ret = idChip (chip); if (!ret && descriptor->alarmNumber) { - if ((ret = sensors_get_feature (*chip, descriptor->alarmNumber, &tmp))) { + if ((ret = sensors_get_feature (chip, descriptor->alarmNumber, &tmp))) { sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, descriptor->alarmNumber, sensors_strerror (ret)); ret = 20; } else { @@ -153,7 +153,7 @@ doKnownChip } } if (!ret && descriptor->beepNumber) { - if ((ret = sensors_get_feature (*chip, descriptor->beepNumber, &tmp))) { + if ((ret = sensors_get_feature (chip, descriptor->beepNumber, &tmp))) { sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, descriptor->beepNumber, sensors_strerror (ret)); ret = 21; } else { @@ -180,7 +180,7 @@ doKnownChip double values[MAX_DATA]; for (subindex = 0; !ret && (feature->dataNumbers[subindex] >= 0); ++ subindex) { - if ((ret = sensors_get_feature (*chip, feature->dataNumbers[subindex], values + subindex))) { + if ((ret = sensors_get_feature (chip, feature->dataNumbers[subindex], values + subindex))) { sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, feature->dataNumbers[subindex], sensors_strerror (ret)); ret = 23; } @@ -215,7 +215,7 @@ setChip int ret = 0; if ((ret = idChip (chip))) { sensorLog (LOG_ERR, "Error identifying chip: %s", chip->prefix); - } else if ((ret = sensors_do_chip_sets (*chip))) { + } else if ((ret = sensors_do_chip_sets (chip))) { sensorLog (LOG_ERR, "Error performing chip sets: %s: %s", chip->prefix, sensors_strerror (ret)); ret = 50; } else { @@ -252,7 +252,7 @@ doChips while ((ret == 0) && ((chip = sensors_get_detected_chips (&i)) != NULL)) { for (j = 0; (ret == 0) && (j < numChipNames); ++ j) { - if (sensors_match_chip (*chip, chipNames[j])) { + if (sensors_match_chip (chip, &chipNames[j])) { ret = doChip (chip, action); } } diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index b37870f8..cce2c1b1 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -91,8 +91,8 @@ void print_vid_info(const sensors_chip_name *name, int f_vid, int label_size) char *label; double vid; - if (!sensors_get_label(*name, f_vid, &label) - && !sensors_get_feature(*name,f_vid,&vid) ) { + if (!sensors_get_label(name, f_vid, &label) + && !sensors_get_feature(name, f_vid, &vid)) { print_label(label, label_size); printf("%+6.3f V\n", vid); } @@ -107,13 +107,13 @@ void print_unknown_chip(const sensors_chip_name *name) double val; a = 0; - while((data=sensors_get_all_features(*name, &a))) { - if (sensors_get_label(*name, data->number, &label)) { + while((data=sensors_get_all_features(name, &a))) { + if (sensors_get_label(name, data->number, &label)) { printf("ERROR: Can't get feature `%s' data!\n",data->name); continue; } if (data->mode & SENSORS_MODE_R) { - if(sensors_get_feature(*name,data->number,&val)) { + if(sensors_get_feature(name, data->number, &val)) { printf("ERROR: Can't get feature `%s' data!\n",data->name); continue; } diff --git a/prog/sensors/chips_generic.c b/prog/sensors/chips_generic.c index 5e026b97..2d2058f8 100644 --- a/prog/sensors/chips_generic.c +++ b/prog/sensors/chips_generic.c @@ -30,7 +30,7 @@ static int get_feature_value(const sensors_chip_name *name, const sensors_feature_data *feature, double *val) { - return sensors_get_feature(*name, feature->number, val); + return sensors_get_feature(name, feature->number, val); } static void sensors_get_available_features(const sensors_chip_name *name, @@ -43,7 +43,7 @@ static void sensors_get_available_features(const sensors_chip_name *name, { const sensors_feature_data *iter; - while((iter = sensors_get_all_features(*name, &i)) && + while((iter = sensors_get_all_features(name, &i)) && iter->mapping == feature->number) { int indx; @@ -68,8 +68,8 @@ static int sensors_get_label_size(const sensors_chip_name *name) unsigned int max_size = 11; /* Initialised to 11 as minumum label-width */ i = 0; - while((iter = sensors_get_all_features(*name, &i))) { - if (!sensors_get_label(*name, iter->number, &label) && + while((iter = sensors_get_all_features(name, &i))) { + if (!sensors_get_label(name, iter->number, &label) && strlen(label) > max_size) max_size = strlen(label); free(label); @@ -98,7 +98,7 @@ static void print_generic_chip_temp(const sensors_chip_name *name, short has_features[SENSORS_FEATURE_TEMP_SENS - SENSORS_FEATURE_TEMP] = {0, }; double feature_vals[SENSORS_FEATURE_TEMP_SENS - SENSORS_FEATURE_TEMP] = {0.0, }; - if (sensors_get_label(*name, feature->number, &label)) { + if (sensors_get_label(name, feature->number, &label)) { free(label); printf("ERROR: Can't get temperature label!\n"); return; @@ -212,7 +212,7 @@ static void print_generic_chip_in(const sensors_chip_name *name, double val, alarm_max, alarm_min; char *label; - if (sensors_get_label(*name, feature->number, &label)) { + if (sensors_get_label(name, feature->number, &label)) { free(label); printf("ERROR: Can't get in label!\n"); return; @@ -275,7 +275,7 @@ static void print_generic_chip_fan(const sensors_chip_name *name, double feature_vals[SENSORS_FEATURE_FAN_DIV - SENSORS_FEATURE_FAN] = {0.0, }; double val; - if (sensors_get_label(*name, feature->number, &label)) { + if (sensors_get_label(name, feature->number, &label)) { printf("ERROR: Can't get fan label!\n"); free(label); return; @@ -326,7 +326,7 @@ void print_generic_chip(const sensors_chip_name *name) label_size = sensors_get_label_size(name); i = 0; - while((feature = sensors_get_all_features(*name, &i))) { + while((feature = sensors_get_all_features(name, &i))) { if (feature->mapping != SENSORS_NO_MAPPING) continue; diff --git a/prog/sensors/main.c b/prog/sensors/main.c index ef52a140..91b03a5e 100644 --- a/prog/sensors/main.c +++ b/prog/sensors/main.c @@ -259,7 +259,7 @@ int do_the_real_work(int *error) *error = 0; for (chip_nr = 0; (chip = sensors_get_detected_chips(&chip_nr));) for(i = 0; i < chips_count; i++) - if (sensors_match_chip(*chip,chips[i])) { + if (sensors_match_chip(chip, &chips[i])) { if(do_sets) { if (do_a_set(*chip)) *error = 1; @@ -276,7 +276,7 @@ int do_a_set(sensors_chip_name name) { int res; - if ((res = sensors_do_chip_sets(name))) { + if ((res = sensors_do_chip_sets(&name))) { if (res == -SENSORS_ERR_PROC) { fprintf(stderr,"%s: %s for writing;\n",sprintf_chip_name(name), sensors_strerror(res));