2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-04 08:15:13 +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

@@ -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 (chip = NULL; (chip = sensors_for_all_config_chips(name, chip));)
for (i = 0; i < chip->labels_count; i++) 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); label = strdup(chip->labels[i].value);
goto sensors_get_label_exit; goto sensors_get_label_exit;
} }

View File

@@ -26,7 +26,7 @@
/* Look up a resource in the intern chip list, and return a pointer to it. /* 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 Do not modify the struct the return value points to! Returns NULL if
not found. */ not found. */
extern const sensors_chip_feature *sensors_lookup_feature_nr(const sensors_chip_name *chip, const sensors_chip_feature *sensors_lookup_feature_nr(const sensors_chip_name *chip,
int feature); int feature);
/* Check whether the chip name is an 'absolute' name, which can only match /* Check whether the chip name is an 'absolute' name, which can only match

View File

@@ -21,12 +21,12 @@
#define LIB_SENSORS_CONF_H #define LIB_SENSORS_CONF_H
/* This is defined in conf-lex.l */ /* This is defined in conf-lex.l */
extern int sensors_yylex(void); int sensors_yylex(void);
extern char sensors_lex_error[]; extern char sensors_lex_error[];
extern int sensors_yylineno; extern int sensors_yylineno;
extern FILE *sensors_yyin; extern FILE *sensors_yyin;
/* This is defined in conf-parse.y */ /* This is defined in conf-parse.y */
extern int sensors_yyparse(void); int sensors_yyparse(void);
#endif /* LIB_SENSORS_CONF_H */ #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_count = 0;
int sensors_proc_bus_max = 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: Parse a chip name to the internal representation. These are valid names:

View File

@@ -29,12 +29,14 @@
/* Kinds of expression operators recognized */ /* Kinds of expression operators recognized */
typedef enum sensors_operation { typedef enum sensors_operation {
sensors_add, sensors_sub, sensors_multiply, sensors_divide, sensors_add, sensors_sub, sensors_multiply, sensors_divide,
sensors_negate, sensors_exp, sensors_log } sensors_operation; sensors_negate, sensors_exp, sensors_log,
} sensors_operation;
/* An expression can have several forms */ /* An expression can have several forms */
typedef enum sensors_expr_kind { typedef enum sensors_expr_kind {
sensors_kind_val, sensors_kind_source, sensors_kind_var, sensors_kind_val, sensors_kind_source, sensors_kind_var,
sensors_kind_sub } sensors_expr_kind; sensors_kind_sub
} sensors_expr_kind;
/* An expression. It is either a floating point value, a variable name, /* An expression. It is either a floating point value, a variable name,
an operation on subexpressions, or the special value 'sub' } */ an operation on subexpressions, or the special value 'sub' } */

View File

@@ -23,15 +23,15 @@
#include "general.h" #include "general.h"
static void sensors_default_parse_error(const char *err, int lineno); 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) = void (*sensors_parse_error) (const char *err, int lineno) =
sensors_default_parse_error; sensors_default_parse_error;
void (*sensors_fatal_error) (const char *proc, const char *err) = void (*sensors_fatal_error) (const char *proc, const char *err) =
sensors_default_fatal_error; sensors_default_fatal_error;
static const char *errorlist[] = static const char *errorlist[] = {
{ /* Unknown error */ "sensors_strerror: Unknown error!", /* Unknown error */ "sensors_strerror: Unknown error!",
/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name", /* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name",
/* SENSORS_ERR_NO_ENTRY */ "No such feature known", /* SENSORS_ERR_NO_ENTRY */ "No such feature known",
/* SENSORS_ERR_ACCESS */ "Can't read or write", /* SENSORS_ERR_ACCESS */ "Can't read or write",
@@ -41,8 +41,8 @@ static const char *errorlist[] =
/* SENSORS_ERR_BUS_NAME */ "Can't parse bus name", /* SENSORS_ERR_BUS_NAME */ "Can't parse bus name",
/* SENSORS_ERR_PARSE */ "General parse error", /* SENSORS_ERR_PARSE */ "General parse error",
/* SENSORS_ERR_ACCESS_W */ "Can't write", /* SENSORS_ERR_ACCESS_W */ "Can't write",
/* SENSORS_ERR_ACCESS_R */ "Can't read" /* SENSORS_ERR_ACCESS_R */ "Can't read",
}; };
const char *sensors_strerror(int errnum) const char *sensors_strerror(int errnum)
{ {
@@ -55,11 +55,11 @@ const char *sensors_strerror(int errnum)
void sensors_default_parse_error(const char *err, int lineno) 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) void sensors_default_fatal_error(const char *proc, const char *err)
{ {
fprintf(stderr,"Fatal error in `%s': %s\n",proc,err); fprintf(stderr, "Fatal error in `%s': %s\n", proc, err);
exit(1); exit(1);
} }

View File

@@ -39,7 +39,7 @@ extern "C" {
/* This function returns a pointer to a string which describes the error. /* This function returns a pointer to a string which describes the error.
errnum may be negative (the corresponding positive error is returned). errnum may be negative (the corresponding positive error is returned).
You may not modify the result! */ 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 /* 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 value, and your own function is called instead of the default (which

View File

@@ -33,7 +33,8 @@ void sensors_malloc_array(void *list, int *num_el, int *max_el, int el_size)
*my_list = malloc(el_size*A_BUNCH); *my_list = malloc(el_size*A_BUNCH);
if (! *my_list) if (! *my_list)
sensors_fatal_error("sensors_malloc_array","Allocating new elements"); sensors_fatal_error("sensors_malloc_array",
"Allocating new elements");
*max_el = A_BUNCH; *max_el = A_BUNCH;
*num_el = 0; *num_el = 0;
} }
@@ -55,9 +56,10 @@ void sensors_add_array_el(const void *el, void *list, int *num_el,
void **my_list = (void *)list; void **my_list = (void *)list;
if (*num_el + 1 > *max_el) { if (*num_el + 1 > *max_el) {
new_max_el = *max_el + A_BUNCH; new_max_el = *max_el + A_BUNCH;
*my_list = realloc(*my_list,new_max_el * el_size); *my_list = realloc(*my_list, new_max_el * el_size);
if (! *my_list) if (! *my_list)
sensors_fatal_error("sensors_add_array_el","Allocating new elements"); sensors_fatal_error("sensors_add_array_el",
"Allocating new elements");
*max_el = new_max_el; *max_el = new_max_el;
} }
memcpy(((char *) *my_list) + *num_el * el_size, el, el_size); memcpy(((char *) *my_list) + *num_el * el_size, el, el_size);
@@ -72,9 +74,10 @@ void sensors_add_array_els(const void *els, int nr_els, void *list,
if (*num_el + nr_els > *max_el) { if (*num_el + nr_els > *max_el) {
new_max_el = (*max_el + nr_els + A_BUNCH); new_max_el = (*max_el + nr_els + A_BUNCH);
new_max_el -= new_max_el % A_BUNCH; new_max_el -= new_max_el % A_BUNCH;
*my_list = realloc(*my_list,new_max_el * el_size); *my_list = realloc(*my_list, new_max_el * el_size);
if (! *my_list) if (! *my_list)
sensors_fatal_error("sensors_add_array_els","Allocating new elements"); sensors_fatal_error("sensors_add_array_els",
"Allocating new elements");
*max_el = new_max_el; *max_el = new_max_el;
} }
memcpy(((char *)*my_list) + *num_el * el_size, els, el_size * nr_els); memcpy(((char *)*my_list) + *num_el * el_size, els, el_size * nr_els);
@@ -85,6 +88,6 @@ void sensors_add_array_els(const void *els, int nr_els, void *list,
void sensors_strip_of_spaces(char *name) void sensors_strip_of_spaces(char *name)
{ {
int i; int i;
for (i = strlen(name)-1; (i>=0) && (name[i] == ' '); i--); for (i = strlen(name) - 1; i >= 0 && name[i] == ' '; i--);
name[i+1] = '\0'; name[i + 1] = '\0';
} }

View File

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

View File

@@ -43,7 +43,8 @@ int sensors_init(FILE *input)
if (!sensors_init_sysfs()) if (!sensors_init_sysfs())
return -SENSORS_ERR_PROC; return -SENSORS_ERR_PROC;
if ((res = sensors_read_sysfs_bus()) || (res = sensors_read_sysfs_chips())) if ((res = sensors_read_sysfs_bus()) ||
(res = sensors_read_sysfs_chips()))
return res; return res;
if ((res = sensors_scanner_init(input))) if ((res = sensors_scanner_init(input)))
return -SENSORS_ERR_PARSE; return -SENSORS_ERR_PARSE;

View File

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

View File

@@ -172,11 +172,11 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
dyn_features = calloc(fnum, sizeof(sensors_chip_feature)); dyn_features = calloc(fnum, sizeof(sensors_chip_feature));
if (dyn_features == NULL) { if (dyn_features == NULL) {
sensors_fatal_error(__FUNCTION__,"Out of memory"); sensors_fatal_error(__FUNCTION__, "Out of memory");
} }
fnum = 0; fnum = 0;
for(i = 0; i < ALL_POSSIBLE_FEATURES; i++) { for (i = 0; i < ALL_POSSIBLE_FEATURES; i++) {
if (features[i].data.name) { if (features[i].data.name) {
dyn_features[fnum] = features[i]; dyn_features[fnum] = features[i];
fnum++; fnum++;

View File

@@ -22,11 +22,11 @@
extern char sensors_sysfs_mount[]; 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 */ /* Read a value out of a sysfs attribute file */
int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature, int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature,