From: Tomasz Bursztyka Date: Mon, 13 Aug 2012 10:28:51 +0000 (+0300) Subject: iptables: Refactor default return code usage X-Git-Tag: 1.5~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8035d366aec97363953f69ebe1f9b360e0011a6;p=platform%2Fupstream%2Fconnman.git iptables: Refactor default return code usage --- diff --git a/src/iptables.c b/src/iptables.c index 531e9337..cce2fb5a 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -1533,7 +1533,8 @@ static int iptables_command(int argc, char *argv[]) xt_rm = NULL; xt_m = NULL; xt_t = NULL; - ret = 0; + /* Default code for options parsing */ + ret = -EINVAL; /* extension's options will generate false-positives errors */ opterr = 0; @@ -1670,10 +1671,8 @@ static int iptables_command(int argc, char *argv[]) table_name = optarg; table = iptables_init(table_name); - if (table == NULL) { - ret = -EINVAL; + if (table == NULL) goto out; - } break; @@ -1686,7 +1685,6 @@ static int iptables_command(int argc, char *argv[]) connman_error("Invalid option"); - ret = -EINVAL; goto out; default: @@ -1769,12 +1767,13 @@ static int iptables_command(int argc, char *argv[]) table_name = "filter"; table = iptables_init(table_name); - if (table == NULL) { - ret = -EINVAL; + if (table == NULL) goto out; - } } + /* Option parsing went fine, falling back to succes code */ + ret = 0; + if (delete_chain != NULL) { printf("Delete chain %s\n", delete_chain); @@ -1786,7 +1785,6 @@ static int iptables_command(int argc, char *argv[]) if (dump) { iptables_dump(table); - ret = 0; goto out; }