mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-01 06:45:24 +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:
@@ -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;
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
/* 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,
|
||||
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
|
||||
|
@@ -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 */
|
||||
|
@@ -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:
|
||||
|
@@ -29,12 +29,14 @@
|
||||
/* 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;
|
||||
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_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' } */
|
||||
|
14
lib/error.c
14
lib/error.c
@@ -23,15 +23,15 @@
|
||||
#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;
|
||||
|
||||
static const char *errorlist[] =
|
||||
{ /* Unknown error */ "sensors_strerror: Unknown 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",
|
||||
@@ -41,8 +41,8 @@ static const char *errorlist[] =
|
||||
/* 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"
|
||||
};
|
||||
/* SENSORS_ERR_ACCESS_R */ "Can't read",
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
fprintf(stderr, "Fatal error in `%s': %s\n", proc, err);
|
||||
exit(1);
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
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;
|
||||
*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;
|
||||
if (*num_el + 1 > *max_el) {
|
||||
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)
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
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);
|
||||
*my_list = realloc(*my_list, new_max_el * el_size);
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
int i;
|
||||
for (i = strlen(name)-1; (i>=0) && (name[i] == ' '); i--);
|
||||
name[i+1] = '\0';
|
||||
for (i = strlen(name) - 1; i >= 0 && name[i] == ' '; i--);
|
||||
name[i + 1] = '\0';
|
||||
}
|
||||
|
@@ -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,
|
||||
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,
|
||||
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);
|
||||
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);
|
||||
|
||||
/* 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]))
|
||||
|
||||
|
@@ -43,7 +43,8 @@ int sensors_init(FILE *input)
|
||||
|
||||
if (!sensors_init_sysfs())
|
||||
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;
|
||||
if ((res = sensors_scanner_init(input)))
|
||||
return -SENSORS_ERR_PARSE;
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -172,11 +172,11 @@ 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++;
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user