diff mbox

[3/5] ipset: coalesce two ifs

Message ID 20140908143043.16930.51865.stgit@jonathan.eitzenberger.org
State Not Applicable
Delegated to: Jozsef Kadlecsik
Headers show

Commit Message

holger@eitzenberger.org Sept. 8, 2014, 2:30 p.m. UTC
Because they are doing the same for both IPSET_CMD_LIST and
IPSET_CMD_SAVE.

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
---
 lib/session.c |    6 ++----
 1 file changed, 2 insertions(+), 4 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

Jozsef Kadlecsik Sept. 14, 2014, 7:10 p.m. UTC | #1
On Mon, 8 Sep 2014, Holger Eitzenberger wrote:

> Because they are doing the same for both IPSET_CMD_LIST and
> IPSET_CMD_SAVE.
> 
> Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
> ---
>  lib/session.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/session.c b/lib/session.c
> index 7a719b2..d4fe836 100644
> --- a/lib/session.c
> +++ b/lib/session.c
> @@ -1936,13 +1936,11 @@ ipset_cmd(struct ipset_session *session, enum ipset_cmd cmd, uint32_t lineno)
>  	session->lineno = lineno;
>  
>  	/* Set default output mode */
> -	if (cmd == IPSET_CMD_LIST) {
> +	if (cmd == IPSET_CMD_LIST || cmd == IPSET_CMD_SAVE) {
>  		if (session->mode == IPSET_LIST_NONE)
>  			session->mode = IPSET_LIST_PLAIN;
> -	} else if (cmd == IPSET_CMD_SAVE) {
> -		if (session->mode == IPSET_LIST_NONE)
> -			session->mode = IPSET_LIST_SAVE;
>  	}
> +
>  	/* Start the root element in XML mode */
>  	if ((cmd == IPSET_CMD_LIST || cmd == IPSET_CMD_SAVE) &&
>  	    session->mode == IPSET_LIST_XML)
> 

The two ifs don't do the same thing: by coalescing them the safe mode 
would be broken (unless XML mode is specified). So this patch is skipped.

Best regards,
Jozsef
-
E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
          H-1525 Budapest 114, POB. 49, Hungary
--
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/lib/session.c b/lib/session.c
index 7a719b2..d4fe836 100644
--- a/lib/session.c
+++ b/lib/session.c
@@ -1936,13 +1936,11 @@  ipset_cmd(struct ipset_session *session, enum ipset_cmd cmd, uint32_t lineno)
 	session->lineno = lineno;
 
 	/* Set default output mode */
-	if (cmd == IPSET_CMD_LIST) {
+	if (cmd == IPSET_CMD_LIST || cmd == IPSET_CMD_SAVE) {
 		if (session->mode == IPSET_LIST_NONE)
 			session->mode = IPSET_LIST_PLAIN;
-	} else if (cmd == IPSET_CMD_SAVE) {
-		if (session->mode == IPSET_LIST_NONE)
-			session->mode = IPSET_LIST_SAVE;
 	}
+
 	/* Start the root element in XML mode */
 	if ((cmd == IPSET_CMD_LIST || cmd == IPSET_CMD_SAVE) &&
 	    session->mode == IPSET_LIST_XML)