aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hemminger <stephen@networkplumber.org>2023-11-17 09:16:14 -0800
committerStephen Hemminger <stephen@networkplumber.org>2023-11-17 09:16:14 -0800
commite6e5f774f433f66ab5b2363434295dccf82bd785 (patch)
tree6a4b23f3bcc1858369abe6728e80a12ef31dfc94
parent2c3ebb2ae08a634615e56303d784ddb366e47f04 (diff)
downloadiproute2-next-e6e5f774f433f66ab5b2363434295dccf82bd785.tar.gz
ip: move get_failed blocks
Rather than doing goto back into the middle of an earlier if() statement. Move the error returns to the end of the functions to follow kernel coding practice. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r--ip/link_gre.c14
-rw-r--r--ip/link_gre6.c14
-rw-r--r--ip/link_ip6tnl.c14
-rw-r--r--ip/link_iptnl.c14
-rw-r--r--ip/link_vti.c14
-rw-r--r--ip/link_vti6.c14
6 files changed, 42 insertions, 42 deletions
diff --git a/ip/link_gre.c b/ip/link_gre.c
index 6d71864c1..010b4824b 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -109,13 +109,8 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
const struct rtattr *rta;
- if (rtnl_talk(&rth, &req.n, &answer) < 0) {
-get_failed:
- fprintf(stderr,
- "Failed to get existing tunnel info.\n");
- free(answer);
- return -1;
- }
+ if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ goto get_failed;
len = answer->nlmsg_len;
len -= NLMSG_LENGTH(sizeof(*ifi));
@@ -423,6 +418,11 @@ get_failed:
addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
return 0;
+
+get_failed:
+ fprintf(stderr, "Failed to get existing tunnel info.\n");
+ free(answer);
+ return -1;
}
static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 4d1c65748..fc3e35f7e 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -111,13 +111,8 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
const struct rtattr *rta;
- if (rtnl_talk(&rth, &req.n, &answer) < 0) {
-get_failed:
- fprintf(stderr,
- "Failed to get existing tunnel info.\n");
- free(answer);
- return -1;
- }
+ if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ goto get_failed;
len = answer->nlmsg_len;
len -= NLMSG_LENGTH(sizeof(*ifi));
@@ -441,6 +436,11 @@ get_failed:
addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
return 0;
+
+get_failed:
+ fprintf(stderr, "Failed to get existing tunnel info.\n");
+ free(answer);
+ return -1;
}
static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index 3a30dca93..c2a05cee3 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -97,13 +97,8 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
const struct rtattr *rta;
- if (rtnl_talk(&rth, &req.n, &answer) < 0) {
-get_failed:
- fprintf(stderr,
- "Failed to get existing tunnel info.\n");
- free(answer);
- return -1;
- }
+ if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ goto get_failed;
len = answer->nlmsg_len;
len -= NLMSG_LENGTH(sizeof(*ifi));
@@ -326,6 +321,11 @@ get_failed:
addattr16(n, 1024, IFLA_IPTUN_ENCAP_DPORT, htons(encapdport));
return 0;
+
+get_failed:
+ fprintf(stderr, "Failed to get existing tunnel info.\n");
+ free(answer);
+ return -1;
}
static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 879202f71..49c3ae261 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -101,13 +101,8 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
const struct rtattr *rta;
- if (rtnl_talk(&rth, &req.n, &answer) < 0) {
-get_failed:
- fprintf(stderr,
- "Failed to get existing tunnel info.\n");
- free(answer);
- return -1;
- }
+ if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ goto get_failed;
len = answer->nlmsg_len;
len -= NLMSG_LENGTH(sizeof(*ifi));
@@ -350,6 +345,11 @@ get_failed:
}
return 0;
+
+get_failed:
+ fprintf(stderr, "Failed to get existing tunnel info.\n");
+ free(answer);
+ return -1;
}
static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
diff --git a/ip/link_vti.c b/ip/link_vti.c
index 7a95dc02d..2106a9d2c 100644
--- a/ip/link_vti.c
+++ b/ip/link_vti.c
@@ -65,13 +65,8 @@ static int vti_parse_opt(struct link_util *lu, int argc, char **argv,
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
const struct rtattr *rta;
- if (rtnl_talk(&rth, &req.n, &answer) < 0) {
-get_failed:
- fprintf(stderr,
- "Failed to get existing tunnel info.\n");
- free(answer);
- return -1;
- }
+ if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ goto get_failed;
len = answer->nlmsg_len;
len -= NLMSG_LENGTH(sizeof(*ifi));
@@ -157,6 +152,11 @@ get_failed:
addattr32(n, 1024, IFLA_VTI_LINK, link);
return 0;
+
+get_failed:
+ fprintf(stderr, "Failed to get existing tunnel info.\n");
+ free(answer);
+ return -1;
}
static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
diff --git a/ip/link_vti6.c b/ip/link_vti6.c
index aaf701d33..7362f336a 100644
--- a/ip/link_vti6.c
+++ b/ip/link_vti6.c
@@ -67,13 +67,8 @@ static int vti6_parse_opt(struct link_util *lu, int argc, char **argv,
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
const struct rtattr *rta;
- if (rtnl_talk(&rth, &req.n, &answer) < 0) {
-get_failed:
- fprintf(stderr,
- "Failed to get existing tunnel info.\n");
- free(answer);
- return -1;
- }
+ if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ goto get_failed;
len = answer->nlmsg_len;
len -= NLMSG_LENGTH(sizeof(*ifi));
@@ -159,6 +154,11 @@ get_failed:
addattr32(n, 1024, IFLA_VTI_LINK, link);
return 0;
+
+get_failed:
+ fprintf(stderr, "Failed to get existing tunnel info.\n");
+ free(answer);
+ return -1;
}
static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])