summaryrefslogtreecommitdiff
path: root/src/iptables.c
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2012-08-13 13:28:51 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-08-14 15:08:45 +0300
commitc8035d366aec97363953f69ebe1f9b360e0011a6 (patch)
tree7843bc1bd8185047586fbca6eae126d2eb23bc4a /src/iptables.c
parent2b22d03a45da5ff1b2a9ef24456b86946da1b582 (diff)
downloadconnman-c8035d366aec97363953f69ebe1f9b360e0011a6.tar.gz
connman-c8035d366aec97363953f69ebe1f9b360e0011a6.tar.bz2
connman-c8035d366aec97363953f69ebe1f9b360e0011a6.zip
iptables: Refactor default return code usage
Diffstat (limited to 'src/iptables.c')
-rw-r--r--src/iptables.c16
1 files changed, 7 insertions, 9 deletions
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;
}