summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--lib/Module.mk4
-rw-r--r--lib/access.c40
-rw-r--r--lib/access.h9
-rw-r--r--lib/data.h9
-rw-r--r--lib/error.c5
-rw-r--r--lib/general.h2
-rw-r--r--lib/init.c2
-rw-r--r--lib/proc.c1
-rw-r--r--lib/sysfs.c5
-rw-r--r--prog/dump/isadump.c6
-rw-r--r--prog/sensors/chips_generic.c4
-rw-r--r--prog/sensors/main.c4
13 files changed, 52 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index d4a3cbf8..15ebaf06 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
diff --git a/lib/Module.mk b/lib/Module.mk
index da38e47a..14b220c9 100644
--- a/lib/Module.mk
+++ b/lib/Module.mk
@@ -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))
diff --git a/lib/access.c b/lib/access.c
index b6c5eb7b..620e5d87 100644
--- a/lib/access.c
+++ b/lib/access.c
@@ -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;
diff --git a/lib/access.h b/lib/access.h
index 32c274ec..60068b7c 100644
--- a/lib/access.h
+++ b/lib/access.h
@@ -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 */
diff --git a/lib/data.h b/lib/data.h
index 3be0a485..5bf2b0c9 100644
--- a/lib/data.h
+++ b/lib/data.h
@@ -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 */
diff --git a/lib/error.c b/lib/error.c
index 62addd89..1a869f6c 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -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];
}
diff --git a/lib/general.h b/lib/general.h
index 1bb308ac..5a5dee1a 100644
--- a/lib/general.h
+++ b/lib/general.h
@@ -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 */
diff --git a/lib/init.c b/lib/init.c
index 865232c4..856ba232 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -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;
}
diff --git a/lib/proc.c b/lib/proc.c
index acbea114..6edcb00f 100644
--- a/lib/proc.c
+++ b/lib/proc.c
@@ -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...
diff --git a/lib/sysfs.c b/lib/sysfs.c
index 3cb63b1d..c63cb75d 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -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++;
diff --git a/prog/dump/isadump.c b/prog/dump/isadump.c
index 04eee8d3..55fd9005 100644
--- a/prog/dump/isadump.c
+++ b/prog/dump/isadump.c
@@ -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;
diff --git a/prog/sensors/chips_generic.c b/prog/sensors/chips_generic.c
index dc2b7583..6984f881 100644
--- a/prog/sensors/chips_generic.c
+++ b/prog/sensors/chips_generic.c
@@ -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))) {
diff --git a/prog/sensors/main.c b/prog/sensors/main.c
index 48aa9d08..03c6670e 100644
--- a/prog/sensors/main.c
+++ b/prog/sensors/main.c
@@ -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");