netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 3/6] netlink: style fixes
Date: Sun, 11 Jan 2015 08:09:39 +0000	[thread overview]
Message-ID: <1420963782-21189-4-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1420963782-21189-1-git-send-email-kaber@trash.net>

Remove style discrepancies between different netlink I/O functions:

- we don't use brackets for single line statements
- most functions don't have a newline between error reporting and exit

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 src/netlink.c | 39 +++++++++++++++------------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/src/netlink.c b/src/netlink.c
index cb22c30..af56d22 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -128,6 +128,7 @@ struct nft_table *alloc_nft_table(const struct handle *h)
 	nft_table_attr_set_u32(nlt, NFT_TABLE_ATTR_FAMILY, h->family);
 	if (h->table != NULL)
 		nft_table_attr_set(nlt, NFT_TABLE_ATTR_NAME, h->table);
+
 	return nlt;
 }
 
@@ -145,6 +146,7 @@ struct nft_chain *alloc_nft_chain(const struct handle *h)
 		nft_chain_attr_set_u64(nlc, NFT_CHAIN_ATTR_HANDLE, h->handle);
 	if (h->chain != NULL)
 		nft_chain_attr_set_str(nlc, NFT_CHAIN_ATTR_NAME, h->chain);
+
 	return nlc;
 }
 
@@ -164,10 +166,10 @@ struct nft_rule *alloc_nft_rule(const struct handle *h)
 		nft_rule_attr_set_u64(nlr, NFT_RULE_ATTR_HANDLE, h->handle);
 	if (h->position)
 		nft_rule_attr_set_u64(nlr, NFT_RULE_ATTR_POSITION, h->position);
-	if (h->comment) {
+	if (h->comment)
 		nft_rule_attr_set_data(nlr, NFT_RULE_ATTR_USERDATA,
 				       h->comment, strlen(h->comment) + 1);
-	}
+
 	return nlr;
 }
 
@@ -178,6 +180,7 @@ struct nft_rule_expr *alloc_nft_expr(const char *name)
 	nle = nft_rule_expr_alloc(name);
 	if (nle == NULL)
 		memory_allocation_error();
+
 	return nle;
 }
 
@@ -223,10 +226,9 @@ static struct nft_set_elem *alloc_nft_setelem(const struct expr *expr)
 		case EXPR_VERDICT:
 			nft_set_elem_attr_set_u32(nlse, NFT_SET_ELEM_ATTR_VERDICT,
 						  expr->right->verdict);
-			if (expr->chain != NULL) {
+			if (expr->chain != NULL)
 				nft_set_elem_attr_set(nlse, NFT_SET_ELEM_ATTR_CHAIN,
 						nld.chain, strlen(nld.chain));
-			}
 			break;
 		case EXPR_VALUE:
 			nft_set_elem_attr_set(nlse, NFT_SET_ELEM_ATTR_DATA,
@@ -238,10 +240,9 @@ static struct nft_set_elem *alloc_nft_setelem(const struct expr *expr)
 		}
 	}
 
-	if (expr->flags & EXPR_F_INTERVAL_END) {
+	if (expr->flags & EXPR_F_INTERVAL_END)
 		nft_set_elem_attr_set_u32(nlse, NFT_SET_ELEM_ATTR_FLAGS,
 					  NFT_SET_ELEM_INTERVAL_END);
-	}
 
 	return nlse;
 }
@@ -364,11 +365,10 @@ int netlink_add_rule_batch(struct netlink_ctx *ctx,
 	netlink_linearize_rule(ctx, nlr, rule);
 	err = mnl_nft_rule_batch_add(nlr, flags | NLM_F_EXCL, ctx->seqnum);
 	nft_rule_free(nlr);
-	if (err < 0) {
+	if (err < 0)
 		netlink_io_error(ctx, &rule->location,
 				 "Could not add rule to batch: %s",
 				 strerror(errno));
-	}
 	return err;
 }
 
@@ -398,7 +398,6 @@ int netlink_del_rule_batch(struct netlink_ctx *ctx, const struct handle *h,
 	if (err < 0)
 		netlink_io_error(ctx, loc, "Could not delete rule to batch: %s",
 				 strerror(errno));
-
 	return err;
 }
 
@@ -536,10 +535,9 @@ static int netlink_add_chain_batch(struct netlink_ctx *ctx,
 				      ctx->seqnum);
 	nft_chain_free(nlc);
 
-	if (err < 0) {
+	if (err < 0)
 		netlink_io_error(ctx, loc, "Could not add chain: %s",
 				 strerror(errno));
-	}
 	return err;
 }
 
@@ -587,10 +585,9 @@ static int netlink_rename_chain_batch(struct netlink_ctx *ctx,
 	err = mnl_nft_chain_batch_add(nlc, 0, ctx->seqnum);
 	nft_chain_free(nlc);
 
-	if (err < 0) {
+	if (err < 0)
 		netlink_io_error(ctx, loc, "Could not rename chain: %s",
 				 strerror(errno));
-	}
 	return err;
 }
 
@@ -615,10 +612,9 @@ static int netlink_del_chain_compat(struct netlink_ctx *ctx,
 	err = mnl_nft_chain_delete(nf_sock, nlc, 0);
 	nft_chain_free(nlc);
 
-	if (err < 0) {
+	if (err < 0)
 		netlink_io_error(ctx, loc, "Could not delete chain: %s",
 				 strerror(errno));
-	}
 	return err;
 }
 
@@ -634,10 +630,9 @@ static int netlink_del_chain_batch(struct netlink_ctx *ctx,
 	err = mnl_nft_chain_batch_del(nlc, 0, ctx->seqnum);
 	nft_chain_free(nlc);
 
-	if (err < 0) {
+	if (err < 0)
 		netlink_io_error(ctx, loc, "Could not delete chain: %s",
 				 strerror(errno));
-	}
 	return err;
 }
 
@@ -801,10 +796,9 @@ static int netlink_add_table_batch(struct netlink_ctx *ctx,
 				      ctx->seqnum);
 	nft_table_free(nlt);
 
-	if (err < 0) {
+	if (err < 0)
 		netlink_io_error(ctx, loc, "Could not add table: %s",
 				 strerror(errno));
-	}
 	return err;
 }
 
@@ -846,10 +840,9 @@ static int netlink_del_table_batch(struct netlink_ctx *ctx,
 	err = mnl_nft_table_batch_del(nlt, 0, ctx->seqnum);
 	nft_table_free(nlt);
 
-	if (err < 0) {
+	if (err < 0)
 		netlink_io_error(ctx, loc, "Could not delete table: %s",
 				 strerror(errno));
-	}
 	return err;
 }
 
@@ -1114,10 +1107,9 @@ static int netlink_add_set_batch(struct netlink_ctx *ctx,
 	netlink_dump_set(nls);
 
 	err = mnl_nft_set_batch_add(nls, NLM_F_EXCL, ctx->seqnum);
-	if (err < 0) {
+	if (err < 0)
 		netlink_io_error(ctx, &set->location, "Could not add set: %s",
 				 strerror(errno));
-	}
 	nft_set_free(nls);
 
 	return err;
@@ -1457,7 +1449,6 @@ int netlink_flush_ruleset(struct netlink_ctx *ctx, const struct handle *h,
 	if (err < 0)
 		netlink_io_error(ctx, loc, "Could not flush the ruleset: %s",
 				 strerror(errno));
-
 	return err;
 }
 
-- 
2.1.0


  parent reply	other threads:[~2015-01-11  8:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-11  8:09 [PATCH 0/6] netlink: style and readability fixes Patrick McHardy
2015-01-11  8:09 ` [PATCH 1/6] netlink: remove unnecessary temporary variable Patrick McHardy
2015-01-11  8:09 ` [PATCH 2/6] netlink: style fixes Patrick McHardy
2015-01-11  8:09 ` Patrick McHardy [this message]
2015-01-11  8:09 ` [PATCH 4/6] netlink: readability fixes Patrick McHardy
2015-01-11  8:09 ` [PATCH 5/6] netlink_delinearize: rename netlink_parse_*_sreg/dreg functions Patrick McHardy
2015-01-11  8:09 ` [PATCH 6/6] netlink_delinearize: cleanup hard to read code Patrick McHardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420963782-21189-4-git-send-email-kaber@trash.net \
    --to=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).