summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-08-31 14:42:20 +0000
committerJean Delvare <khali@linux-fr.org>2007-08-31 14:42:20 +0000
commita82c6b0476fac3fa5c46f542fa9a1eac79f855a8 (patch)
tree244fd79ee5f09a12ad909fe9935420c35caa559e /lib
parent02dc2e66796c57a8f1a5035764e824f7beb745b5 (diff)
downloadlm-sensors-git-a82c6b0476fac3fa5c46f542fa9a1eac79f855a8.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/access.c6
-rw-r--r--lib/access.h4
-rw-r--r--lib/conf.h4
-rw-r--r--lib/data.c2
-rw-r--r--lib/data.h104
-rw-r--r--lib/error.c54
-rw-r--r--lib/error.h2
-rw-r--r--lib/general.c83
-rw-r--r--lib/general.h16
-rw-r--r--lib/init.c185
-rw-r--r--lib/scanner.h4
-rw-r--r--lib/sensors.h2
-rw-r--r--lib/sysfs.c40
-rw-r--r--lib/sysfs.h6
14 files changed, 259 insertions, 253 deletions
diff --git a/lib/access.c b/lib/access.c
index e7d6c98e..af8167cb 100644
--- a/lib/access.c
+++ b/lib/access.c
@@ -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;
}
diff --git a/lib/access.h b/lib/access.h
index b5639246..736f2c1d 100644
--- a/lib/access.h
+++ b/lib/access.h
@@ -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
diff --git a/lib/conf.h b/lib/conf.h
index 3fa07504..adf2136b 100644
--- a/lib/conf.h
+++ b/lib/conf.h
@@ -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 */
diff --git a/lib/data.c b/lib/data.c
index 6e0dbc9d..489a592c 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -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:
diff --git a/lib/data.h b/lib/data.h
index 5f089eda..25818a6f 100644
--- a/lib/data.h
+++ b/lib/data.h
@@ -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;
diff --git a/lib/error.c b/lib/error.c
index 1a869f6c..9c90b624 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -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);
}
diff --git a/lib/error.h b/lib/error.h
index 9ff72ffb..47febd68 100644
--- a/lib/error.h
+++ b/lib/error.h
@@ -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
diff --git a/lib/general.c b/lib/general.c
index 9374b58c..f032d494 100644
--- a/lib/general.c
+++ b/lib/general.c
@@ -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';
}
diff --git a/lib/general.h b/lib/general.h
index 5a5dee1a..73e5e620 100644
--- a/lib/general.h
+++ b/lib/general.h
@@ -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]))
diff --git a/lib/init.c b/lib/init.c
index 13c26f8e..bf7137c1 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -39,137 +39,138 @@ static void free_expr(sensors_expr *expr);
int sensors_init(FILE *input)
{
- 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;
+ 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;
}
void sensors_cleanup(void)
{
- int i;
-
- 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_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;
+ int i;
+
+ 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_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;
-
- 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->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->ignores_count; i++)
- free_ignore(&chip->ignores[i]);
- free(chip->ignores);
- chip->ignores_count = chip->ignores_max = 0;
+ 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->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->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;
}
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);
}
diff --git a/lib/scanner.h b/lib/scanner.h
index d8e9a413..b926fd06 100644
--- a/lib/scanner.h
+++ b/lib/scanner.h
@@ -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
diff --git a/lib/sensors.h b/lib/sensors.h
index 699dcec6..b853687e 100644
--- a/lib/sensors.h
+++ b/lib/sensors.h
@@ -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
}
diff --git a/lib/sysfs.c b/lib/sysfs.c
index fcc93ced..a0e3c9a2 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -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;
diff --git a/lib/sysfs.h b/lib/sysfs.h
index 6aaa3508..847011bf 100644
--- a/lib/sysfs.h
+++ b/lib/sysfs.h
@@ -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,