Add some more warning flags, and fix these warnings.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4545 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2007-07-03 16:03:22 +00:00
1 parent c7c77845d2
commit b79274babd
13 files changed
+52 -42

No files matched your search

+2 -1
View File
@@ -140,7 +140,8 @@ endif
ifeq ($(WARN),1)
ALL_CFLAGS += -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wnested-externs -Winline
-Wcast-align -Wwrite-strings -Wnested-externs -Winline -W \
-Wmissing-prototypes -Wundef
endif
ALL_CPPFLAGS += $(CPPFLAGS)
+2 -2
View File
@@ -87,9 +87,9 @@ INCLUDEFILES += $(LIBCSOURCES:.c=.ld) $(LIBCSOURCES:.c=.ad)
# Special warning prevention for flex-generated files
$(MODULE_DIR)/conf-lex.ao: $(MODULE_DIR)/conf-lex.c
$(CC) $(ARCPPFLAGS) $(ARCFLAGS) -Wno-unused -c $< -o $@
$(CC) $(ARCPPFLAGS) $(ARCFLAGS) -Wno-unused -Wno-missing-prototypes -c $< -o $@
$(MODULE_DIR)/conf-lex.lo: $(MODULE_DIR)/conf-lex.c
$(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -Wno-unused -c $< -o $@
$(CC) $(LIBCPPFLAGS) $(LIBCFLAGS) -Wno-unused -Wno-missing-prototypes -c $< -o $@
REMOVELIBST := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBDIR)/%,$(LIB_DIR)/$(LIBSTLIBNAME))
REMOVELIBSH := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(LIBDIR)/%,$(LIB_DIR)/$(LIBSHLIBNAME))
+23 -17
View File
@@ -488,23 +488,30 @@ int sensors_do_chip_sets(sensors_chip_name name)
calling sensors_do_chip_sets with an all wildcards chip name */
int sensors_do_all_sets(void)
{
sensors_chip_name name = { SENSORS_CHIP_NAME_PREFIX_ANY,
SENSORS_CHIP_NAME_BUS_ANY,
SENSORS_CHIP_NAME_ADDR_ANY
static const sensors_chip_name name = {
.prefix = SENSORS_CHIP_NAME_PREFIX_ANY,
.bus = SENSORS_CHIP_NAME_BUS_ANY,
.addr = SENSORS_CHIP_NAME_ADDR_ANY,
};
return sensors_do_chip_sets(name);
}
/* Static mappings for use by sensors_feature_get_type() */
struct feature_subtype_match
{
const char *name;
sensors_feature_type type;
};
struct feature_type_match
{
const char *name;
sensors_feature_type type;
struct feature_type_match *submatches;
const struct feature_subtype_match *submatches;
};
static struct feature_type_match temp_matches[] = {
static const struct feature_subtype_match temp_matches[] = {
{ "max", SENSORS_FEATURE_TEMP_MAX },
{ "max_hyst", SENSORS_FEATURE_TEMP_MAX_HYST },
{ "min", SENSORS_FEATURE_TEMP_MIN },
@@ -516,29 +523,29 @@ static struct feature_type_match temp_matches[] = {
{ "crit_alarm", SENSORS_FEATURE_TEMP_CRIT_ALARM },
{ "fault", SENSORS_FEATURE_TEMP_FAULT },
{ "type", SENSORS_FEATURE_TEMP_SENS },
{ 0 }
{ NULL, 0 }
};
static struct feature_type_match in_matches[] = {
static const struct feature_subtype_match in_matches[] = {
{ "min", SENSORS_FEATURE_IN_MIN },
{ "max", SENSORS_FEATURE_IN_MAX },
{ "alarm", SENSORS_FEATURE_IN_ALARM },
{ "min_alarm", SENSORS_FEATURE_IN_MIN_ALARM },
{ "max_alarm", SENSORS_FEATURE_IN_MAX_ALARM },
{ 0 }
{ NULL, 0 }
};
static struct feature_type_match fan_matches[] = {
static const struct feature_subtype_match fan_matches[] = {
{ "min", SENSORS_FEATURE_FAN_MIN },
{ "div", SENSORS_FEATURE_FAN_DIV },
{ "alarm", SENSORS_FEATURE_FAN_ALARM },
{ "fault", SENSORS_FEATURE_FAN_FAULT },
{ 0 }
{ NULL, 0 }
};
static struct feature_type_match cpu_matches[] = {
static const struct feature_subtype_match cpu_matches[] = {
{ "vid", SENSORS_FEATURE_VID },
{ 0 }
{ NULL, 0 }
};
static struct feature_type_match matches[] = {
@@ -546,7 +553,6 @@ static struct feature_type_match matches[] = {
{ "in%d%c", SENSORS_FEATURE_IN, in_matches },
{ "fan%d%c", SENSORS_FEATURE_FAN, fan_matches },
{ "cpu%d%c", SENSORS_FEATURE_UNKNOWN, cpu_matches },
{ 0 }
};
/* Return the feature type based on the feature name */
@@ -555,13 +561,13 @@ sensors_feature_type sensors_feature_get_type(
{
char c;
int i, nr, count;
struct feature_type_match *submatches;
const struct feature_subtype_match *submatches;
for(i = 0; matches[i].name != 0; i++)
for (i = 0; i < ARRAY_SIZE(matches); i++)
if ((count = sscanf(feature->name, matches[i].name, &nr, &c)))
break;
if (matches[i].name == NULL) /* no match */
if (i == ARRAY_SIZE(matches)) /* no match */
return SENSORS_FEATURE_UNKNOWN;
else if (count == 1) /* single type */
return matches[i].type;
@@ -571,7 +577,7 @@ sensors_feature_type sensors_feature_get_type(
return SENSORS_FEATURE_UNKNOWN;
submatches = matches[i].submatches;
for(i = 0; submatches[i].name != 0; i++)
for (i = 0; submatches[i].name != NULL; i++)
if (!strcmp(strchr(feature->name, '_') + 1, submatches[i].name))
return submatches[i].type;
-9
View File
@@ -29,13 +29,4 @@
extern const sensors_chip_feature *sensors_lookup_feature_nr(const sensors_chip_name *chip,
int feature);
/* Substitute configuration bus numbers with real-world /proc bus numbers
in the chips lists */
extern int sensors_substitute_busses(void);
/* Parse an i2c bus name into its components. Returns 0 on succes, a value from
error.h on failure. */
extern int sensors_parse_i2cbus_name(const char *name, int *res);
#endif /* def LIB_SENSORS_ACCESS_H */
+9
View File
@@ -170,4 +170,13 @@ extern int sensors_proc_bus_max;
(el), &sensors_proc_bus, &sensors_proc_bus_count,\
&sensors_proc_bus_max, sizeof(struct sensors_bus))
/* Substitute configuration bus numbers with real-world /proc bus numbers
in the chips lists */
int sensors_substitute_busses(void);
/* Parse an i2c bus name into its components. Returns 0 on succes, a value from
error.h on failure. */
int sensors_parse_i2cbus_name(const char *name, int *res);
#endif /* def LIB_SENSORS_DATA_H */
+2 -3
View File
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "error.h"
#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);
@@ -43,13 +44,11 @@ static const char *errorlist[] =
/* SENSORS_ERR_ACCESS_R */ "Can't read"
};
#define ERROR_LIST_LEN (sizeof(errorlist) / sizeof(char *))
const char *sensors_strerror(int errnum)
{
if (errnum < 0)
errnum = -errnum;
if (errnum >= ERROR_LIST_LEN)
if (errnum >= ARRAY_SIZE(errorlist))
errnum = 0;
return errorlist[errnum];
}
+2
View File
@@ -36,4 +36,6 @@ extern void sensors_add_array_els(const void *els, int nr_els, void *list,
/* Strip a string of all terminating spaces */
extern void sensors_strip_of_spaces(char *name);
#define ARRAY_SIZE(arr) (int)(sizeof(arr) / sizeof((arr)[0]))
#endif /* LIB_SENSORS_GENERAL */
+1 -1
View File
@@ -49,7 +49,7 @@ int sensors_init(FILE *input)
return -SENSORS_ERR_PARSE;
if ((res = sensors_yyparse()))
return -SENSORS_ERR_PARSE;
if ((res = sensors_substitute_busses()));
if ((res = sensors_substitute_busses()))
return res;
return 0;
}
+1
View File
@@ -25,6 +25,7 @@
#include "data.h"
#include "error.h"
#include "access.h"
#include "proc.h"
/* This reads a feature from a sysfs file.
Sysfs uses a one-value-per file system...
+3 -2
View File
@@ -83,7 +83,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
memset(features, 0, sizeof(features));
dlist_for_each_data(attrs, attr, struct sysfs_attribute) {
sensors_chip_feature feature = { { 0, }, 0, };
sensors_chip_feature feature;
name = attr->name;
if (!strcmp(name, "name")) {
@@ -91,6 +91,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
continue;
}
memset(&feature, 0, sizeof(sensors_chip_feature));
/* check for _input extension and remove */
i = strlen(name);
if (i > 6 && !strcmp(name + i - 6, "_input"))
@@ -180,7 +181,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
}
fnum = 0;
for(i = 0; i < sizeof(features)/sizeof(sensors_chip_feature); i++) {
for(i = 0; i < ARRAY_SIZE(features); i++) {
if (features[i].data.name) {
dyn_features[fnum] = features[i];
fnum++;
+3 -3
View File
@@ -47,7 +47,7 @@
unsigned long isa_io_base = 0; /* XXX for now */
#endif /* __powerpc__ */
void help(void)
static void help(void)
{
fprintf(stderr,
"Syntax for I2C-like access:\n"
@@ -56,7 +56,7 @@ void help(void)
" isadump [-y] -f ADDRESS [RANGE [BANK [BANKREG]]]\n");
}
int default_bankreg(int flat, int addrreg, int datareg)
static int default_bankreg(int flat, int addrreg, int datareg)
{
if (flat) {
return 0x09; /* Works for National Semiconductor
@@ -71,7 +71,7 @@ int default_bankreg(int flat, int addrreg, int datareg)
return 0x4e; /* Works for Winbond ISA chips, default */
}
int set_bank(int flat, int addrreg, int datareg, int bank, int bankreg)
static int set_bank(int flat, int addrreg, int datareg, int bank, int bankreg)
{
int oldbank;
+2 -2
View File
@@ -64,7 +64,7 @@ static void sensors_get_available_features(const sensors_chip_name *name,
iter->mapping != SENSORS_NO_MAPPING &&
iter->mapping == feature->number) {
sensors_feature_type type = sensors_feature_get_type(iter);
unsigned int indx;
int indx;
if (type == SENSORS_FEATURE_UNKNOWN)
continue;
@@ -87,7 +87,7 @@ static int sensors_get_label_size(const sensors_chip_name *name)
int i, j, valid;
const sensors_feature_data *iter;
char *label;
int max_size = 11; /* Initialised to 11 as minumum label-width */
unsigned int max_size = 11; /* Initialised to 11 as minumum label-width */
i = j = 0;
while((iter = sensors_get_all_features(*name, &i, &j))) {
+2 -2
View File
@@ -95,7 +95,7 @@ void print_version(void)
/* This examines global var config_file, and leaves the name there too.
It also opens config_file. */
void open_config_file(const char* config_file_name)
static void open_config_file(const char* config_file_name)
{
if (!strcmp(config_file_name,"-")) {
config_file = stdin;
@@ -110,7 +110,7 @@ void open_config_file(const char* config_file_name)
}
}
void close_config_file(const char* config_file_name)
static void close_config_file(const char* config_file_name)
{
if (fclose(config_file) == EOF) {
fprintf(stderr,"Could not close config file\n");