diff mbox

[libnftables,5/6] test: style cleanup

Message ID 20131031123639.32572.83332.stgit@nfdev.cica.es
State Changes Requested
Headers show

Commit Message

Arturo Borrero Oct. 31, 2013, 12:36 p.m. UTC
Some style cleanups.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 tests/nft-parsing-test.c |   34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 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

Comments

Pablo Neira Ayuso Nov. 3, 2013, 9:33 p.m. UTC | #1
On Thu, Oct 31, 2013 at 01:36:39PM +0100, Arturo Borrero Gonzalez wrote:
> Some style cleanups.
> 
> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> ---
>  tests/nft-parsing-test.c |   34 ++++++++++++++++++++++------------
>  1 file changed, 22 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c
> index 3d26c3a..e147e79 100644
> --- a/tests/nft-parsing-test.c
> +++ b/tests/nft-parsing-test.c
> @@ -193,8 +193,10 @@ static int test_json(const char *filename)
>  	if (json_object_get(root, "table") != NULL) {
>  		t = nft_table_alloc();
>  		if (t != NULL) {
> -			if (nft_table_parse(t, NFT_TABLE_PARSE_JSON, json) == 0)
> -				ret = compare_test(TEST_JSON_TABLE, t, filename);
> +			if (nft_table_parse(t,
> +					    NFT_TABLE_PARSE_JSON, json) == 0)
> +				ret = compare_test(TEST_JSON_TABLE,
> +						   t, filename);
>  			else
>  				goto failparsing;

If you need to break lines like this, it usually means that this code
needs to be split in smaller functions. Please, send me a clean up by
encapsulating the tests in new smaller functions, eg. test_json_table().
--
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
diff mbox

Patch

diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c
index 3d26c3a..e147e79 100644
--- a/tests/nft-parsing-test.c
+++ b/tests/nft-parsing-test.c
@@ -193,8 +193,10 @@  static int test_json(const char *filename)
 	if (json_object_get(root, "table") != NULL) {
 		t = nft_table_alloc();
 		if (t != NULL) {
-			if (nft_table_parse(t, NFT_TABLE_PARSE_JSON, json) == 0)
-				ret = compare_test(TEST_JSON_TABLE, t, filename);
+			if (nft_table_parse(t,
+					    NFT_TABLE_PARSE_JSON, json) == 0)
+				ret = compare_test(TEST_JSON_TABLE,
+						   t, filename);
 			else
 				goto failparsing;
 
@@ -203,8 +205,10 @@  static int test_json(const char *filename)
 	} else if (json_object_get(root, "chain") != NULL) {
 		c = nft_chain_alloc();
 		if (c != NULL) {
-			if (nft_chain_parse(c, NFT_CHAIN_PARSE_JSON, json) == 0)
-				ret = compare_test(TEST_JSON_CHAIN, c, filename);
+			if (nft_chain_parse(c,
+					    NFT_CHAIN_PARSE_JSON, json) == 0)
+				ret = compare_test(TEST_JSON_CHAIN,
+						   c, filename);
 			else
 				goto failparsing;
 
@@ -213,8 +217,10 @@  static int test_json(const char *filename)
 	} else if (json_object_get(root, "rule") != NULL) {
 		r = nft_rule_alloc();
 		if (r != NULL) {
-			if (nft_rule_parse(r, NFT_RULE_PARSE_JSON, json) == 0)
-				ret = compare_test(TEST_JSON_RULE, r, filename);
+			if (nft_rule_parse(r,
+					   NFT_RULE_PARSE_JSON, json) == 0)
+				ret = compare_test(TEST_JSON_RULE,
+						   r, filename);
 			else
 				goto failparsing;
 
@@ -229,17 +235,19 @@  static int test_json(const char *filename)
 				goto failparsing;
 
 			nft_set_free(s);
-			}
+		}
 	} else if (json_object_get(root, "nftables") != NULL) {
 		rs = nft_ruleset_alloc();
 		if (rs != NULL) {
-			if (nft_ruleset_parse(rs, NFT_RULESET_PARSE_JSON, json) == 0)
-				ret = compare_test(TEST_JSON_RULESET, rs, filename);
+			if (nft_ruleset_parse(rs,
+					      NFT_RULESET_PARSE_JSON, json) == 0)
+				ret = compare_test(TEST_JSON_RULESET,
+						   rs, filename);
 			else
 				goto failparsing;
 
 			nft_ruleset_free(rs);
-			}
+		}
 	}
 
 	free(json);
@@ -292,7 +300,8 @@  static int test_xml(const char *filename)
 		t = nft_table_alloc();
 		if (t != NULL) {
 			if (nft_table_parse(t, NFT_TABLE_PARSE_XML, xml) == 0)
-				ret = compare_test(TEST_XML_TABLE, t, filename);
+				ret = compare_test(TEST_XML_TABLE,
+						   t, filename);
 			else
 				goto failparsing;
 
@@ -302,7 +311,8 @@  static int test_xml(const char *filename)
 		c = nft_chain_alloc();
 		if (c != NULL) {
 			if (nft_chain_parse(c, NFT_CHAIN_PARSE_XML, xml) == 0)
-				ret = compare_test(TEST_XML_CHAIN, c, filename);
+				ret = compare_test(TEST_XML_CHAIN,
+						   c, filename);
 			else
 				goto failparsing;