[PATCH nftlb] src: add -W and compilation warnings that result from it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



config.c: In function ‘config_file’:
config.c:60:30: warning: ordered comparison of pointer with integer zero [-Wextra]
  if ((fd = fopen(file, "r")) <= 0) {
                              ^~

nft.c: In function ‘get_ndv_base’:
nft.c:173:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < n_ndv_base_rules; i++) {
                ^

Add -Wno-unused-parameter to silence the following warning:

onfig.c: In function ‘config_json_string’:
config.c:142:46: warning: unused parameter ‘level’ [-Wunused-parame
 void config_json_string(json_t *element, int level)
                                              ^~~~~

since this may be intentional as all these functions take the level parameter.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 Make_global.am | 2 +-
 src/config.c   | 3 ++-
 src/nft.c      | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Make_global.am b/Make_global.am
index 64e8e2341156..10bb4c54c18e 100644
--- a/Make_global.am
+++ b/Make_global.am
@@ -1,4 +1,4 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include
 
-AM_CFLAGS = -Wall \
+AM_CFLAGS = -std=gnu99 -W -Wall -Wno-unused-parameter \
 	${LIBNFTABLES_CFLAGS} ${LIBJSON_CFLAGS} -lev
diff --git a/src/config.c b/src/config.c
index c14039781503..2aa596435b29 100644
--- a/src/config.c
+++ b/src/config.c
@@ -57,7 +57,8 @@ int config_file(const char *file)
 	json_t		*root;
 	int		ret = EXIT_SUCCESS;
 
-	if ((fd = fopen(file, "r")) <= 0) {
+	fd = fopen(file, "r");
+	if (fd == NULL) {
 		fprintf(stderr, "Error open configuration file %s\n", file);
 		syslog(LOG_ERR, "Error open configuration file %s", file);
 		return EXIT_FAILURE;
diff --git a/src/nft.c b/src/nft.c
index 669dc8812c00..5f9845f279bd 100644
--- a/src/nft.c
+++ b/src/nft.c
@@ -168,7 +168,7 @@ void get_ports(const char *ptr, int *first, int *last)
 
 struct if_base_rule * get_ndv_base(char *ifname)
 {
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < n_ndv_base_rules; i++) {
 		if (strcmp(ndv_base_rules[i]->ifname, ifname) == 0)
-- 
2.11.0


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux