projects
/
platform
/
upstream
/
connman.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2b22d03
)
iptables: Refactor default return code usage
author
Tomasz Bursztyka
<tomasz.bursztyka@linux.intel.com>
Mon, 13 Aug 2012 10:28:51 +0000
(13:28 +0300)
committer
Patrik Flykt
<patrik.flykt@linux.intel.com>
Tue, 14 Aug 2012 12:08:45 +0000
(15:08 +0300)
src/iptables.c
patch
|
blob
|
history
diff --git
a/src/iptables.c
b/src/iptables.c
index
531e933
..
cce2fb5
100644
(file)
--- 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;
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;
/* 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);
table_name = optarg;
table = iptables_init(table_name);
- if (table == NULL) {
- ret = -EINVAL;
+ if (table == NULL)
goto out;
goto out;
- }
break;
break;
@@
-1686,7
+1685,6
@@
static int iptables_command(int argc, char *argv[])
connman_error("Invalid option");
connman_error("Invalid option");
- ret = -EINVAL;
goto out;
default:
goto out;
default:
@@
-1769,12
+1767,13
@@
static int iptables_command(int argc, char *argv[])
table_name = "filter";
table = iptables_init(table_name);
table_name = "filter";
table = iptables_init(table_name);
- if (table == NULL) {
- ret = -EINVAL;
+ if (table == NULL)
goto out;
goto out;
- }
}
}
+ /* Option parsing went fine, falling back to succes code */
+ ret = 0;
+
if (delete_chain != NULL) {
printf("Delete chain %s\n", delete_chain);
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);
if (dump) {
iptables_dump(table);
- ret = 0;
goto out;
}
goto out;
}