[PATCH] ebtables: Fix build errors and warnings

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

 



Since commit b1cdae87f25021eb835872d86d6e7206bd421c3f, make fails thusly:

> libebtc.c: In function 'ebt_reinit_extensions':
> libebtc.c:275:11: error: 'union <anonymous>' has no member named 'revision'
>     m->m->u.revision = m->revision;
>            ^
> libebtc.c: In function 'ebt_check_rule_exists':
> libebtc.c:555:21: error: 'union <anonymous>' has no member named 'revision'
>            m_l2->m->u.revision != m->m->u.revision)) {
>                      ^
> libebtc.c:555:41: error: 'union <anonymous>' has no member named 'revision'
>            m_l2->m->u.revision != m->m->u.revision)) {
>                                          ^
> libebtc.c: In function 'ebt_register_match':
> libebtc.c:1215:9: error: 'union <anonymous>' has no member named 'revision'
>   m->m->u.revision = m->revision;
>          ^
The cause of this failure is that the commit updated include/ebtables.h but
libebtc.c uses include/linux/netfilter_bridge/ebtables.h via
include/ebtables_u.h (gcc -E -C verifies this).

The 2 versions of ebtables.h looked to me to be otherwise close enough, so
amended ebtables_u.h to use the newer one.

Makefile insists on being warning-free, so cleared up warnings. Apart from
unused variables, there was also the issue that the diagnostic macro
ebt_print_error2 *returns* (i.e. makes its caller return) and returns -1. This
is unsuitable for use in functions which do not return a value, so introduced
ebt_print_error3 to do this.

Signed-off-by: Duncan Roe <duncan_roe@xxxxxxxxxxxxxxx>
---
 extensions/ebt_string.c | 25 +++++++++++--------------
 include/ebtables_u.h    |  4 +++-
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/extensions/ebt_string.c b/extensions/ebt_string.c
index 793f5df..9550c41 100644
--- a/extensions/ebt_string.c
+++ b/extensions/ebt_string.c
@@ -71,7 +71,7 @@ static void parse_string(const char *s, struct xt_string_info *info)
 		info->patlen = strnlen(s, XT_STRING_MAX_PATTERN_SIZE);
 		return;
 	}
-	ebt_print_error2("STRING too long \"%s\"", s);
+	ebt_print_error3("STRING too long \"%s\"", s);
 }
 
 static void parse_hex_string(const char *s, struct xt_string_info *info)
@@ -83,14 +83,14 @@ static void parse_hex_string(const char *s, struct xt_string_info *info)
 	slen = strlen(s);
 
 	if (slen == 0) {
-		ebt_print_error2("STRING must contain at least one char");
+		ebt_print_error3("STRING must contain at least one char");
 	}
 
 	while (i < slen) {
 		if (s[i] == '\\' && !hex_f) {
 			literal_f = 1;
 		} else if (s[i] == '\\') {
-			ebt_print_error2("Cannot include literals in hex data");
+			ebt_print_error3("Cannot include literals in hex data");
 		} else if (s[i] == '|') {
 			if (hex_f)
 				hex_f = 0;
@@ -108,28 +108,28 @@ static void parse_hex_string(const char *s, struct xt_string_info *info)
 
 		if (literal_f) {
 			if (i+1 >= slen) {
-				ebt_print_error2("Bad literal placement at end of string");
+				ebt_print_error3("Bad literal placement at end of string");
 			}
 			info->pattern[sindex] = s[i+1];
 			i += 2;  /* skip over literal char */
 			literal_f = 0;
 		} else if (hex_f) {
 			if (i+1 >= slen) {
-				ebt_print_error2("Odd number of hex digits");
+				ebt_print_error3("Odd number of hex digits");
 			}
 			if (i+2 >= slen) {
 				/* must end with a "|" */
-				ebt_print_error2("Invalid hex block");
+				ebt_print_error3("Invalid hex block");
 			}
 			if (! isxdigit(s[i])) /* check for valid hex char */
-				ebt_print_error2("Invalid hex char '%c'", s[i]);
+				ebt_print_error3("Invalid hex char '%c'", s[i]);
 			if (! isxdigit(s[i+1])) /* check for valid hex char */
-				ebt_print_error2("Invalid hex char '%c'", s[i+1]);
+				ebt_print_error3("Invalid hex char '%c'", s[i+1]);
 			hextmp[0] = s[i];
 			hextmp[1] = s[i+1];
 			hextmp[2] = '\0';
 			if (! sscanf(hextmp, "%x", &schar))
-				ebt_print_error2("Invalid hex char `%c'", s[i]);
+				ebt_print_error3("Invalid hex char `%c'", s[i]);
 			info->pattern[sindex] = (char) schar;
 			if (s[i+2] == ' ')
 				i += 3;  /* spaces included in the hex block */
@@ -140,7 +140,7 @@ static void parse_hex_string(const char *s, struct xt_string_info *info)
 			i++;
 		}
 		if (sindex > XT_STRING_MAX_PATTERN_SIZE)
-			ebt_print_error2("STRING too long \"%s\"", s);
+			ebt_print_error3("STRING too long \"%s\"", s);
 		sindex++;
 	}
 	info->patlen = sindex;
@@ -150,9 +150,6 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry,
 		 unsigned int *flags, struct ebt_entry_match **match)
 {
 	struct xt_string_info *info = (struct xt_string_info *)(*match)->data;
-	int i;
-	int input_string_length = 0;
-	char buf[3] = { 0 };
 
 	switch (c) {
 	case STRING_FROM:
@@ -206,7 +203,7 @@ static void final_check(const struct ebt_u_entry *entry,
 	struct xt_string_info *info = (struct xt_string_info *)match->data;
 
 	if (info->to_offset < info->from_offset) {
-		ebt_print_error2("'to' offset should not be less than 'from' "
+		ebt_print_error3("'to' offset should not be less than 'from' "
 				 "offset");
 	}
 }
diff --git a/include/ebtables_u.h b/include/ebtables_u.h
index 4824a14..7adc5a2 100644
--- a/include/ebtables_u.h
+++ b/include/ebtables_u.h
@@ -25,7 +25,7 @@
 #define EBTABLES_U_H
 #include <netinet/in.h>
 #include <netinet/ether.h>
-#include <linux/netfilter_bridge/ebtables.h>
+#include <ebtables.h>
 #include <linux/netfilter/x_tables.h>
 
 #ifndef IPPROTO_SCTP
@@ -338,6 +338,8 @@ _ch;})
 #define ebt_print_error(format,args...) __ebt_print_error(format, ##args);
 #define ebt_print_error2(format, args...) do {__ebt_print_error(format, ##args); \
    return -1;} while (0)
+#define ebt_print_error3(format, args...) do {__ebt_print_error(format, ##args); \
+   return;} while (0)
 #define ebt_check_option2(flags,mask)	\
 ({ebt_check_option(flags,mask);		\
  if (ebt_errormsg[0] != '\0')		\
-- 
2.9.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