summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2013-05-02 10:51:55 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2013-05-02 10:51:55 +0200
commit18149c6ac307e089abe3dcc078fc3fccf6afc4c6 (patch)
tree8392b520773d700c876a218efdb5c9c176749d95
parentf535c61dc1e3e77ad4b5eefe4f6696514e8cf58d (diff)
Add sparse checking support to userspace
-rw-r--r--Make_global.am7
-rw-r--r--Makefile.am8
-rw-r--r--include/libipset/pfxlen.h2
-rw-r--r--lib/Makefile.am6
-rw-r--r--src/Makefile.am6
5 files changed, 26 insertions, 3 deletions
diff --git a/Make_global.am b/Make_global.am
index 33986a2..29b5678 100644
--- a/Make_global.am
+++ b/Make_global.am
@@ -81,3 +81,10 @@ AM_CFLAGS += -g -g3 -ggdb -gdwarf-2 -DIPSET_DEBUG -Wall -Werror
else
AM_CFLAGS += -O2 -DNDEBUG
endif
+
+SPARSE = sparse
+SPARSE_FLAGS = -Wsparse-all -I../include
+IPSET_AM_V_CHECK = $(ipset_am__v_CHECK_$(V))
+ipset_am__v_CHECK_ = $(ipset_am__v_CHECK_$(AM_DEFAULT_VERBOSITY))
+ipset_am__v_CHECK_0 = @echo " CHECK " $<;
+
diff --git a/Makefile.am b/Makefile.am
index 0806623..3453604 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,11 +17,15 @@ endif
SUBDIRS = include/libipset lib src
+sparse-check:
+ $(MAKE) -C lib sparse-check
+ $(MAKE) -C src sparse-check
+
modules_sparse:
if WITH_KMOD
${MAKE} -C $(KBUILD_OUTPUT) M=$$PWD/kernel/net/netfilter \
- V=$V C=2 CF=-D__CHECK_ENDIAN__ \
- KCFLAGS="-DPACKAGE_VERSION=$(PACKAGE_VERSION)" \
+ V=$V W=1 C=2 CF="-D__CHECK_ENDIAN__ -Wsparse-all" \
+ KCFLAGS="-DPACKAGE_VERSION=$(PACKAGE_VERSION) -DCHECK_KCONFIG -Wextra" \
IP_SET_MAX=$(IP_SET_MAX) KDIR=$$PWD/kernel modules
else
@echo Skipping kernel modules due to --with-kmod=no
diff --git a/include/libipset/pfxlen.h b/include/libipset/pfxlen.h
index 58b4b4f..c2c7e0c 100644
--- a/include/libipset/pfxlen.h
+++ b/include/libipset/pfxlen.h
@@ -18,7 +18,7 @@
* This table works for both IPv4 and IPv6;
* just use prefixlen_netmask_map[prefixlength].ip.
*/
-const union nf_inet_addr prefixlen_netmask_map[] = {
+static const union nf_inet_addr prefixlen_netmask_map[] = {
E(0x00000000, 0x00000000, 0x00000000, 0x00000000),
E(0x80000000, 0x00000000, 0x00000000, 0x00000000),
E(0xC0000000, 0x00000000, 0x00000000, 0x00000000),
diff --git a/lib/Makefile.am b/lib/Makefile.am
index fd853dd..2d22aff 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -35,3 +35,9 @@ libipset_la_SOURCES = \
types_init.c
EXTRA_DIST = $(IPSET_SETTYPE_LIST) libipset.map
+
+sparse-check: $(libipset_la_SOURCES:.c=.d)
+
+%.d: %.c
+ $(IPSET_AM_V_CHECK)\
+ $(SPARSE) $(SPARSE_FLAGS) $(AM_CFLAGS) $(AM_CPPFLAGS) $< || :
diff --git a/src/Makefile.am b/src/Makefile.am
index 717fd14..810efb7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,3 +13,9 @@ endif
endif
dist_man_MANS = ipset.8
+
+sparse-check: $(ipset_SOURCES:.c=.d)
+
+%.d: %.c
+ $(IPSET_AM_V_CHECK)\
+ $(SPARSE) -I.. $(SPARSE_FLAGS) $(AM_CFLAGS) $(AM_CPPFLAGS) $< || :