Skip to contentSkip to conversation

iproute2: avoid exit in case of error.

PATCH Applied David Decotigny 2 participants 3 messages Nov 11, 2016 – Nov 29, 2016

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 2/2 iproute2: a non-expected rtnl message is an error

In reply to David Decotigny
---
 ip/iproute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/iproute.c +1 -1
index dae793b..10d0afe 100644
@@ -320,7 +320,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 	if (n->nlmsg_type != RTM_NEWROUTE && n->nlmsg_type != RTM_DELROUTE) {
 		fprintf(stderr, "Not a route: %08x %08x %08x\n",
 			n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
-		return 0;
+		return -1;
 	}
 	if (filter.flushb && n->nlmsg_type != RTM_NEWROUTE)
 		return 0;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#0 lore raw

PATCH 1/2 iproute2: avoid exit in case of error.

Be consistent with how non-0 print_route() return values are handled
elesewhere: return -1.

---
 ip/iproute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/iproute.c +1 -1
index 98bfad6..dae793b 100644
@@ -1743,7 +1743,7 @@ static int iproute_get(int argc, char **argv)
 
 		if (print_route(NULL, &req.n, (void *)stdout) < 0) {
 			fprintf(stderr, "An error :-)\n");
-			exit(1);
+			return -1;
 		}
 
 		if (req.n.nlmsg_type != RTM_NEWROUTE) {
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw
Quoted 7 lines · On Fri, 11 Nov 2016 10:55:36 -0800 David Decotigny <[email protected]> wrote:

Be consistent with how non-0 print_route() return values are handled
elesewhere: return -1.

---
 ip/iproute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, and queued for next push.
Please use Signed-off-by: on future patches.