2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 22:05:11 +00:00

Mass reindent, coding style and whitespace cleanups.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4736 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2007-08-31 14:42:20 +00:00
parent 02dc2e6679
commit a82c6b0476
14 changed files with 249 additions and 243 deletions

View File

@@ -29,8 +29,8 @@
#include "general.h"
static int sensors_eval_expr(const sensors_chip_name *name,
const sensors_expr *expr,
double val, double *result);
const sensors_expr *expr,
double val, double *result);
/* Compare two chips name descriptions, to see whether they could match.
Return 0 if it does not match, return 1 if it does match. */
@@ -158,7 +158,7 @@ char *sensors_get_label(const sensors_chip_name *name, int feature)
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)){
if (!strcasecmp(featureptr->data.name, chip->labels[i].name)) {
label = strdup(chip->labels[i].value);
goto sensors_get_label_exit;
}

View File

@@ -26,8 +26,8 @@
/* Look up a resource in the intern chip list, and return a pointer to it.
Do not modify the struct the return value points to! Returns NULL if
not found. */
extern const sensors_chip_feature *sensors_lookup_feature_nr(const sensors_chip_name *chip,
int feature);
const sensors_chip_feature *sensors_lookup_feature_nr(const sensors_chip_name *chip,
int feature);
/* Check whether the chip name is an 'absolute' name, which can only match
one chip, or whether it has wildcards. Returns 0 if it is absolute, 1

View File

@@ -21,12 +21,12 @@
#define LIB_SENSORS_CONF_H
/* This is defined in conf-lex.l */
extern int sensors_yylex(void);
int sensors_yylex(void);
extern char sensors_lex_error[];
extern int sensors_yylineno;
extern FILE *sensors_yyin;
/* This is defined in conf-parse.y */
extern int sensors_yyparse(void);
int sensors_yyparse(void);
#endif /* LIB_SENSORS_CONF_H */

View File

@@ -48,7 +48,7 @@ sensors_bus *sensors_proc_bus = NULL;
int sensors_proc_bus_count = 0;
int sensors_proc_bus_max = 0;
static int sensors_substitute_chip(sensors_chip_name *name,int lineno);
static int sensors_substitute_chip(sensors_chip_name *name, int lineno);
/*
Parse a chip name to the internal representation. These are valid names:

View File

@@ -27,95 +27,97 @@
data. */
/* Kinds of expression operators recognized */
typedef enum sensors_operation {
sensors_add, sensors_sub, sensors_multiply, sensors_divide,
sensors_negate, sensors_exp, sensors_log } sensors_operation;
typedef enum sensors_operation {
sensors_add, sensors_sub, sensors_multiply, sensors_divide,
sensors_negate, sensors_exp, sensors_log,
} sensors_operation;
/* An expression can have several forms */
typedef enum sensors_expr_kind {
sensors_kind_val, sensors_kind_source, sensors_kind_var,
sensors_kind_sub } sensors_expr_kind;
sensors_kind_val, sensors_kind_source, sensors_kind_var,
sensors_kind_sub
} sensors_expr_kind;
/* An expression. It is either a floating point value, a variable name,
an operation on subexpressions, or the special value 'sub' } */
struct sensors_expr;
typedef struct sensors_subexpr {
sensors_operation op;
struct sensors_expr *sub1;
struct sensors_expr *sub2;
sensors_operation op;
struct sensors_expr *sub1;
struct sensors_expr *sub2;
} sensors_subexpr;
typedef struct sensors_expr {
sensors_expr_kind kind;
union {
double val;
char *var;
sensors_subexpr subexpr;
} data;
sensors_expr_kind kind;
union {
double val;
char *var;
sensors_subexpr subexpr;
} data;
} sensors_expr;
/* Config file label declaration: a feature name, combined with the label
value */
typedef struct sensors_label {
char *name;
char *value;
int lineno;
char *name;
char *value;
int lineno;
} sensors_label;
/* Config file set declaration: a feature name, combined with an expression */
typedef struct sensors_set {
char *name;
sensors_expr *value;
int lineno;
char *name;
sensors_expr *value;
int lineno;
} sensors_set;
/* Config file compute declaration: a feature name, combined with two
/* Config file compute declaration: a feature name, combined with two
expressions */
typedef struct sensors_compute {
char *name;
sensors_expr *from_proc;
sensors_expr *to_proc;
int lineno;
char *name;
sensors_expr *from_proc;
sensors_expr *to_proc;
int lineno;
} sensors_compute;
/* Config file ignore declaration: a feature name */
typedef struct sensors_ignore {
char *name;
int lineno;
char *name;
int lineno;
} sensors_ignore;
/* A list of chip names, used to represent a config file chips declaration */
typedef struct sensors_chip_name_list {
sensors_chip_name *fits;
int fits_count;
int fits_max;
sensors_chip_name *fits;
int fits_count;
int fits_max;
} sensors_chip_name_list;
/* A config file chip block */
typedef struct sensors_chip {
sensors_chip_name_list chips;
sensors_label *labels;
int labels_count;
int labels_max;
sensors_set *sets;
int sets_count;
int sets_max;
sensors_compute *computes;
int computes_count;
int computes_max;
sensors_ignore *ignores;
int ignores_count;
int ignores_max;
int lineno;
sensors_chip_name_list chips;
sensors_label *labels;
int labels_count;
int labels_max;
sensors_set *sets;
int sets_count;
int sets_max;
sensors_compute *computes;
int computes_count;
int computes_max;
sensors_ignore *ignores;
int ignores_count;
int ignores_max;
int lineno;
} sensors_chip;
/* Config file bus declaration: the bus type and number, combined with adapter
name */
typedef struct sensors_bus {
char *adapter;
sensors_bus_id bus;
int lineno;
char *adapter;
sensors_bus_id bus;
int lineno;
} sensors_bus;
/* Internal data about a single chip feature.
@@ -135,14 +137,14 @@ typedef struct sensors_bus {
scaling is the number of decimal points to scale by.
Divide the read value by 10**scaling to get the real value. */
typedef struct sensors_chip_feature {
sensors_feature_data data;
int scaling;
sensors_feature_data data;
int scaling;
} sensors_chip_feature;
/* Internal data about all features of a type of chip */
typedef struct sensors_chip_features {
struct sensors_chip_name chip;
struct sensors_chip_feature *feature;
struct sensors_chip_name chip;
struct sensors_chip_feature *feature;
} sensors_chip_features;
extern sensors_chip *sensors_config_chips;

View File

@@ -23,43 +23,43 @@
#include "general.h"
static void sensors_default_parse_error(const char *err, int lineno);
static void sensors_default_fatal_error(const char *proc,const char *err);
static void sensors_default_fatal_error(const char *proc, const char *err);
void (*sensors_parse_error) (const char *err, int lineno) =
sensors_default_parse_error;
void (*sensors_fatal_error) (const char *proc, const char *err) =
sensors_default_fatal_error;
void (*sensors_parse_error) (const char *err, int lineno) =
sensors_default_parse_error;
void (*sensors_fatal_error) (const char *proc, const char *err) =
sensors_default_fatal_error;
static const char *errorlist[] =
{ /* Unknown error */ "sensors_strerror: Unknown error!",
/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name",
/* SENSORS_ERR_NO_ENTRY */ "No such feature known",
/* SENSORS_ERR_ACCESS */ "Can't read or write",
/* SENSORS_ERR_PROC */ "Can't access sysfs file",
/* SENSORS_ERR_DIV_ZERO */ "Divide by zero",
/* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name",
/* SENSORS_ERR_BUS_NAME */ "Can't parse bus name",
/* SENSORS_ERR_PARSE */ "General parse error",
/* SENSORS_ERR_ACCESS_W */ "Can't write",
/* SENSORS_ERR_ACCESS_R */ "Can't read"
};
static const char *errorlist[] = {
/* Unknown error */ "sensors_strerror: Unknown error!",
/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name",
/* SENSORS_ERR_NO_ENTRY */ "No such feature known",
/* SENSORS_ERR_ACCESS */ "Can't read or write",
/* SENSORS_ERR_PROC */ "Can't access sysfs file",
/* SENSORS_ERR_DIV_ZERO */ "Divide by zero",
/* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name",
/* SENSORS_ERR_BUS_NAME */ "Can't parse bus name",
/* SENSORS_ERR_PARSE */ "General parse error",
/* SENSORS_ERR_ACCESS_W */ "Can't write",
/* SENSORS_ERR_ACCESS_R */ "Can't read",
};
const char *sensors_strerror(int errnum)
{
if (errnum < 0)
errnum = -errnum;
if (errnum >= ARRAY_SIZE(errorlist))
errnum = 0;
return errorlist[errnum];
}
if (errnum < 0)
errnum = -errnum;
if (errnum >= ARRAY_SIZE(errorlist))
errnum = 0;
return errorlist[errnum];
}
void sensors_default_parse_error(const char *err, int lineno)
{
fprintf(stderr,"Error: Line %d: %s\n",lineno,err);
fprintf(stderr, "Error: Line %d: %s\n", lineno, err);
}
void sensors_default_fatal_error(const char *proc, const char *err)
{
fprintf(stderr,"Fatal error in `%s': %s\n",proc,err);
exit(1);
fprintf(stderr, "Fatal error in `%s': %s\n", proc, err);
exit(1);
}

View File

@@ -39,7 +39,7 @@ extern "C" {
/* This function returns a pointer to a string which describes the error.
errnum may be negative (the corresponding positive error is returned).
You may not modify the result! */
extern const char *sensors_strerror(int errnum);
const char *sensors_strerror(int errnum);
/* This function is called when a parse error is detected. Give it a new
value, and your own function is called instead of the default (which

View File

@@ -29,62 +29,65 @@
void sensors_malloc_array(void *list, int *num_el, int *max_el, int el_size)
{
void **my_list = (void **)list;
void **my_list = (void **)list;
*my_list = malloc(el_size*A_BUNCH);
if (! *my_list)
sensors_fatal_error("sensors_malloc_array","Allocating new elements");
*max_el = A_BUNCH;
*num_el = 0;
*my_list = malloc(el_size*A_BUNCH);
if (! *my_list)
sensors_fatal_error("sensors_malloc_array",
"Allocating new elements");
*max_el = A_BUNCH;
*num_el = 0;
}
void sensors_free_array(void *list, int *num_el, int *max_el)
{
void **my_list = (void **)list;
void **my_list = (void **)list;
free(*my_list);
*my_list = NULL;
*num_el = 0;
*max_el = 0;
free(*my_list);
*my_list = NULL;
*num_el = 0;
*max_el = 0;
}
void sensors_add_array_el(const void *el, void *list, int *num_el,
int *max_el, int el_size)
int *max_el, int el_size)
{
int new_max_el;
void **my_list = (void *)list;
if (*num_el + 1 > *max_el) {
new_max_el = *max_el + A_BUNCH;
*my_list = realloc(*my_list,new_max_el * el_size);
if (! *my_list)
sensors_fatal_error("sensors_add_array_el","Allocating new elements");
*max_el = new_max_el;
}
memcpy(((char *) *my_list) + *num_el * el_size, el, el_size);
(*num_el) ++;
int new_max_el;
void **my_list = (void *)list;
if (*num_el + 1 > *max_el) {
new_max_el = *max_el + A_BUNCH;
*my_list = realloc(*my_list, new_max_el * el_size);
if (! *my_list)
sensors_fatal_error("sensors_add_array_el",
"Allocating new elements");
*max_el = new_max_el;
}
memcpy(((char *) *my_list) + *num_el * el_size, el, el_size);
(*num_el) ++;
}
void sensors_add_array_els(const void *els, int nr_els, void *list,
int *num_el, int *max_el, int el_size)
void sensors_add_array_els(const void *els, int nr_els, void *list,
int *num_el, int *max_el, int el_size)
{
int new_max_el;
void **my_list = (void *)list;
if (*num_el + nr_els > *max_el) {
new_max_el = (*max_el + nr_els + A_BUNCH);
new_max_el -= new_max_el % A_BUNCH;
*my_list = realloc(*my_list,new_max_el * el_size);
if (! *my_list)
sensors_fatal_error("sensors_add_array_els","Allocating new elements");
*max_el = new_max_el;
}
memcpy(((char *)*my_list) + *num_el * el_size, els, el_size * nr_els);
*num_el += nr_els;
int new_max_el;
void **my_list = (void *)list;
if (*num_el + nr_els > *max_el) {
new_max_el = (*max_el + nr_els + A_BUNCH);
new_max_el -= new_max_el % A_BUNCH;
*my_list = realloc(*my_list, new_max_el * el_size);
if (! *my_list)
sensors_fatal_error("sensors_add_array_els",
"Allocating new elements");
*max_el = new_max_el;
}
memcpy(((char *)*my_list) + *num_el * el_size, els, el_size * nr_els);
*num_el += nr_els;
}
/* Strip a string of all terminating spaces */
void sensors_strip_of_spaces(char *name)
{
int i;
for (i = strlen(name)-1; (i>=0) && (name[i] == ' '); i--);
name[i+1] = '\0';
int i;
for (i = strlen(name) - 1; i >= 0 && name[i] == ' '; i--);
name[i + 1] = '\0';
}

View File

@@ -25,16 +25,16 @@
made between the current number of elements and the maximum number.
You can only add elements at the end. Primitive, but very useful
for internal use. */
extern void sensors_malloc_array(void *list, int *num_el, int *max_el,
int el_size);
extern void sensors_free_array(void *list, int *num_el, int *max_el);
extern void sensors_add_array_el(const void *el, void *list, int *num_el,
int *max_el, int el_size);
extern void sensors_add_array_els(const void *els, int nr_els, void *list,
int *num_el, int *max_el, int el_size);
void sensors_malloc_array(void *list, int *num_el, int *max_el,
int el_size);
void sensors_free_array(void *list, int *num_el, int *max_el);
void sensors_add_array_el(const void *el, void *list, int *num_el,
int *max_el, int el_size);
void sensors_add_array_els(const void *els, int nr_els, void *list,
int *num_el, int *max_el, int el_size);
/* Strip a string of all terminating spaces */
extern void sensors_strip_of_spaces(char *name);
void sensors_strip_of_spaces(char *name);
#define ARRAY_SIZE(arr) (int)(sizeof(arr) / sizeof((arr)[0]))

View File

@@ -39,137 +39,138 @@ static void free_expr(sensors_expr *expr);
int sensors_init(FILE *input)
{
int res;
int res;
if (!sensors_init_sysfs())
return -SENSORS_ERR_PROC;
if ((res = sensors_read_sysfs_bus()) || (res = sensors_read_sysfs_chips()))
return res;
if ((res = sensors_scanner_init(input)))
return -SENSORS_ERR_PARSE;
if ((res = sensors_yyparse()))
return -SENSORS_ERR_PARSE;
if ((res = sensors_substitute_busses()))
return res;
return 0;
if (!sensors_init_sysfs())
return -SENSORS_ERR_PROC;
if ((res = sensors_read_sysfs_bus()) ||
(res = sensors_read_sysfs_chips()))
return res;
if ((res = sensors_scanner_init(input)))
return -SENSORS_ERR_PARSE;
if ((res = sensors_yyparse()))
return -SENSORS_ERR_PARSE;
if ((res = sensors_substitute_busses()))
return res;
return 0;
}
void sensors_cleanup(void)
{
int i;
int i;
sensors_scanner_exit();
sensors_scanner_exit();
for (i = 0; i < sensors_proc_chips_count; i++) {
free_chip_name(&sensors_proc_chips[i].chip);
free_chip_features(sensors_proc_chips[i].feature);
}
free(sensors_proc_chips);
sensors_proc_chips = NULL;
sensors_proc_chips_count = sensors_proc_chips_max = 0;
for (i = 0; i < sensors_config_busses_count; i++)
free_bus(&sensors_config_busses[i]);
free(sensors_config_busses);
sensors_config_busses = NULL;
sensors_config_busses_count = sensors_config_busses_max = 0;
for (i = 0; i < sensors_proc_chips_count; i++) {
free_chip_name(&sensors_proc_chips[i].chip);
free_chip_features(sensors_proc_chips[i].feature);
}
free(sensors_proc_chips);
sensors_proc_chips = NULL;
sensors_proc_chips_count = sensors_proc_chips_max = 0;
for (i = 0; i < sensors_config_chips_count; i++)
free_chip(&sensors_config_chips[i]);
free(sensors_config_chips);
sensors_config_chips = NULL;
sensors_config_chips_count = sensors_config_chips_max = 0;
for (i = 0; i < sensors_config_busses_count; i++)
free_bus(&sensors_config_busses[i]);
free(sensors_config_busses);
sensors_config_busses = NULL;
sensors_config_busses_count = sensors_config_busses_max = 0;
for (i = 0; i < sensors_proc_bus_count; i++)
free_bus(&sensors_proc_bus[i]);
free(sensors_proc_bus);
sensors_proc_bus = NULL;
sensors_proc_bus_count = sensors_proc_bus_max = 0;
for (i = 0; i < sensors_config_chips_count; i++)
free_chip(&sensors_config_chips[i]);
free(sensors_config_chips);
sensors_config_chips = NULL;
sensors_config_chips_count = sensors_config_chips_max = 0;
for (i = 0; i < sensors_proc_bus_count; i++)
free_bus(&sensors_proc_bus[i]);
free(sensors_proc_bus);
sensors_proc_bus = NULL;
sensors_proc_bus_count = sensors_proc_bus_max = 0;
}
void free_chip_name(sensors_chip_name *name)
{
free(name->prefix);
free(name->path);
free(name->prefix);
free(name->path);
}
void free_chip_features(sensors_chip_feature *features)
{
int i;
int i;
for (i = 0; features[i].data.name; i++)
free(features[i].data.name);
free(features);
for (i = 0; features[i].data.name; i++)
free(features[i].data.name);
free(features);
}
void free_bus(sensors_bus *bus)
{
free(bus->adapter);
free(bus->adapter);
}
void free_chip(sensors_chip *chip)
{
int i;
int i;
for (i = 0; i < chip->chips.fits_count; i++)
free_chip_name(&chip->chips.fits[i]);
free(chip->chips.fits);
chip->chips.fits_count = chip->chips.fits_max = 0;
for (i = 0; i < chip->chips.fits_count; i++)
free_chip_name(&chip->chips.fits[i]);
free(chip->chips.fits);
chip->chips.fits_count = chip->chips.fits_max = 0;
for (i = 0; i < chip->labels_count; i++)
free_label(&chip->labels[i]);
free(chip->labels);
chip->labels_count = chip->labels_max = 0;
for (i = 0; i < chip->labels_count; i++)
free_label(&chip->labels[i]);
free(chip->labels);
chip->labels_count = chip->labels_max = 0;
for (i = 0; i < chip->sets_count; i++)
free_set(&chip->sets[i]);
free(chip->sets);
chip->sets_count = chip->sets_max = 0;
for (i = 0; i < chip->sets_count; i++)
free_set(&chip->sets[i]);
free(chip->sets);
chip->sets_count = chip->sets_max = 0;
for (i = 0; i < chip->computes_count; i++)
free_compute(&chip->computes[i]);
free(chip->computes);
chip->computes_count = chip->computes_max = 0;
for (i = 0; i < chip->computes_count; i++)
free_compute(&chip->computes[i]);
free(chip->computes);
chip->computes_count = chip->computes_max = 0;
for (i = 0; i < chip->ignores_count; i++)
free_ignore(&chip->ignores[i]);
free(chip->ignores);
chip->ignores_count = chip->ignores_max = 0;
for (i = 0; i < chip->ignores_count; i++)
free_ignore(&chip->ignores[i]);
free(chip->ignores);
chip->ignores_count = chip->ignores_max = 0;
}
void free_label(sensors_label *label)
{
free(label->name);
free(label->value);
free(label->name);
free(label->value);
}
void free_set(sensors_set *set)
{
free(set->name);
free_expr(set->value);
free(set->name);
free_expr(set->value);
}
void free_compute(sensors_compute *compute)
{
free(compute->name);
free_expr(compute->from_proc);
free_expr(compute->to_proc);
free(compute->name);
free_expr(compute->from_proc);
free_expr(compute->to_proc);
}
void free_ignore(sensors_ignore *ignore)
{
free(ignore->name);
free(ignore->name);
}
void free_expr(sensors_expr *expr)
{
if ((expr->kind) == sensors_kind_var)
free(expr->data.var);
else if ((expr->kind) == sensors_kind_sub) {
if (expr->data.subexpr.sub1)
free_expr(expr->data.subexpr.sub1);
if (expr->data.subexpr.sub2)
free_expr(expr->data.subexpr.sub2);
}
free(expr);
if ((expr->kind) == sensors_kind_var)
free(expr->data.var);
else if ((expr->kind) == sensors_kind_sub) {
if (expr->data.subexpr.sub1)
free_expr(expr->data.subexpr.sub1);
if (expr->data.subexpr.sub2)
free_expr(expr->data.subexpr.sub2);
}
free(expr);
}

View File

@@ -20,8 +20,8 @@
#ifndef LIB_SENSORS_SCANNER_H
#define LIB_SENSORS_SCANNER_H
extern int sensors_scanner_init(FILE *input);
extern void sensors_scanner_exit(void);
int sensors_scanner_init(FILE *input);
void sensors_scanner_exit(void);
#endif

View File

@@ -176,7 +176,7 @@ typedef struct sensors_feature_data {
Do not try to change the returned structure; you will corrupt internal
data structures. */
const sensors_feature_data *sensors_get_all_features
(const sensors_chip_name *name, int *nr);
(const sensors_chip_name *name, int *nr);
#ifdef __cplusplus
}

View File

@@ -72,24 +72,24 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
sensors_chip_feature *features;
sensors_chip_feature *dyn_features;
char *name;
attrs = sysfs_get_device_attributes(sysdir);
if (attrs == NULL)
return -ENOENT;
/* We use a large sparse table at first to store all found features,
so that we can store them sorted at type and index and then later
create a dense sorted table. */
features = calloc(ALL_POSSIBLE_FEATURES, sizeof(sensors_chip_feature));
if (!features)
sensors_fatal_error(__FUNCTION__, "Out of memory");
dlist_for_each_data(attrs, attr, struct sysfs_attribute) {
sensors_chip_feature feature;
name = attr->name;
int nr;
type = sensors_feature_get_type(name, &nr);
if (type == SENSORS_FEATURE_UNKNOWN)
continue;
@@ -110,7 +110,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
nr--;
break;
}
if (nr >= MAX_SENSORS_PER_TYPE) {
fprintf(stderr, "libsensors error, more sensors of one"
" type then MAX_SENSORS_PER_TYPE, ignoring "
@@ -118,7 +118,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
free(feature.data.name);
continue;
}
/* "calculate" a place to store the feature in our sparse,
sorted table */
if (type == SENSORS_FEATURE_VID) {
@@ -128,19 +128,19 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
MAX_SUB_FEATURES + nr * MAX_SUB_FEATURES +
(type & 0xFF);
}
if (features[i].data.name) {
if (features[i].data.name) {
fprintf(stderr, "libsensors error, trying to add dupli"
"cate feature: %s to dynamic feature table\n",
name);
free(feature.data.name);
continue;
}
/* fill in the other feature members */
feature.data.number = i + 1;
feature.data.type = type;
if ((type & 0x00FF) == 0) {
/* main feature */
feature.data.mapping = SENSORS_NO_MAPPING;
@@ -153,7 +153,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
feature.data.mapping = i - i % MAX_SUB_FEATURES + 1;
feature.data.compute_mapping = feature.data.mapping;
}
if (attr->method & SYSFS_METHOD_SHOW)
feature.data.mode |= SENSORS_MODE_R;
if (attr->method & SYSFS_METHOD_STORE)
@@ -172,19 +172,19 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
dyn_features = calloc(fnum, sizeof(sensors_chip_feature));
if (dyn_features == NULL) {
sensors_fatal_error(__FUNCTION__,"Out of memory");
sensors_fatal_error(__FUNCTION__, "Out of memory");
}
fnum = 0;
for(i = 0; i < ALL_POSSIBLE_FEATURES; i++) {
for (i = 0; i < ALL_POSSIBLE_FEATURES; i++) {
if (features[i].data.name) {
dyn_features[fnum] = features[i];
fnum++;
}
}
chip->feature = dyn_features;
exit_free:
free(features);
return 0;
@@ -268,7 +268,7 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev)
entry.chip.bus.nr = 0;
} else
goto exit_free;
if (sensors_read_dynamic_chip(&entry, dev) < 0)
goto exit_free;
if (!entry.feature) { /* No feature, discard chip */
@@ -440,7 +440,7 @@ int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature,
return 0;
}
int sensors_write_sysfs_attr(const sensors_chip_name *name, int feature,
double value)
{
@@ -451,7 +451,7 @@ int sensors_write_sysfs_attr(const sensors_chip_name *name, int feature,
int dummy;
char check;
const char *suffix = "";
if (!(the_feature = sensors_lookup_feature_nr(name, feature)))
return -SENSORS_ERR_NO_ENTRY;

View File

@@ -22,11 +22,11 @@
extern char sensors_sysfs_mount[];
extern int sensors_init_sysfs(void);
int sensors_init_sysfs(void);
extern int sensors_read_sysfs_chips(void);
int sensors_read_sysfs_chips(void);
extern int sensors_read_sysfs_bus(void);
int sensors_read_sysfs_bus(void);
/* Read a value out of a sysfs attribute file */
int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature,