Patchwork [libnftables] data_reg: Fix conditional code in XML parsing functions

login
register
mail settings
Submitter Arturo Borrero
Date May 28, 2013, 3:06 p.m.
Message ID <20130528150631.5282.3020.stgit@nfdev.cica.es>
Download mbox | patch
Permalink /patch/246883/
State Not Applicable
Headers show

Comments

Arturo Borrero - May 28, 2013, 3:06 p.m.
All the XML parsing chunk was conditional but the main function. I think is better to
do the conditional compilation by function, returning -1 and setting errno = EOPNOTSUPP.


Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 src/expr/data_reg.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira - May 29, 2013, 12:12 p.m.
On Tue, May 28, 2013 at 05:06:31PM +0200, Arturo Borrero wrote:
> All the XML parsing chunk was conditional but the main function. I think is better to
> do the conditional compilation by function, returning -1 and setting errno = EOPNOTSUPP.

Those functions are static, thus not exported. It doesn't make sense
to me to use this approach in this case.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c
index 24497ff..be2b47a 100644
--- a/src/expr/data_reg.c
+++ b/src/expr/data_reg.c
@@ -25,9 +25,9 @@ 
 #include "data_reg.h"
 #include "internal.h"
 
-#ifdef XML_PARSING
 static int nft_data_reg_verdict_xml_parse(union nft_data_reg *reg, char *xml)
 {
+#ifdef XML_PARSING
 	mxml_node_t *tree = NULL;
 	mxml_node_t *node = NULL;
 	char *endptr;
@@ -76,12 +76,15 @@  static int nft_data_reg_verdict_xml_parse(union nft_data_reg *reg, char *xml)
 
 	mxmlDelete(tree);
 	return 0;
+#else
 	errno = EOPNOTSUPP;
 	return -1;
+#endif
 }
 
 static int nft_data_reg_chain_xml_parse(union nft_data_reg *reg, char *xml)
 {
+#ifdef XML_PARSING
 	mxml_node_t *tree = NULL;
 	mxml_node_t *node = NULL;
 
@@ -128,10 +131,15 @@  static int nft_data_reg_chain_xml_parse(union nft_data_reg *reg, char *xml)
 
 	mxmlDelete(tree);
 	return 0;
+#else
+	errno = EOPNOTSUPP;
+	return -1;
+#endif
 }
 
 static int nft_data_reg_value_xml_parse(union nft_data_reg *reg, char *xml)
 {
+#ifdef XML_PARSING
 	mxml_node_t *tree = NULL;
 	mxml_node_t *node = NULL;
 	int i, len;
@@ -211,10 +219,11 @@  static int nft_data_reg_value_xml_parse(union nft_data_reg *reg, char *xml)
 
 	mxmlDelete(tree);
 	return 0;
+#else
 	errno = EOPNOTSUPP;
 	return -1;
-}
 #endif
+}
 
 int nft_data_reg_xml_parse(union nft_data_reg *reg, char *xml)
 {