|
|
4aca6e |
From 78e2bc47a913408cf51b0057230cd8d61d67e305 Mon Sep 17 00:00:00 2001
|
|
|
4aca6e |
From: Sabrina Dubroca <sdubroca@redhat.com>
|
|
|
4aca6e |
Date: Fri, 9 Jun 2017 10:08:08 +0200
|
|
|
4aca6e |
Subject: [PATCH] devlink: Convert conditional in dl_argv_handle_port() to
|
|
|
4aca6e |
switch()
|
|
|
4aca6e |
|
|
|
4aca6e |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1459772
|
|
|
4aca6e |
Upstream Status: iproute2.git commit 7a34b9d098fc
|
|
|
4aca6e |
|
|
|
4aca6e |
commit 7a34b9d098fce6778a02c475fd877e0b34aa7a13
|
|
|
4aca6e |
Author: Hangbin Liu <liuhangbin@gmail.com>
|
|
|
4aca6e |
Date: Sun Oct 9 10:14:18 2016 +0800
|
|
|
4aca6e |
|
|
|
4aca6e |
devlink: Convert conditional in dl_argv_handle_port() to switch()
|
|
|
4aca6e |
|
|
|
4aca6e |
Discovered by Phil's covscan. The final return statement is never reached.
|
|
|
4aca6e |
This is not inherently clear from looking at the code, so change the
|
|
|
4aca6e |
conditional to a switch() statement which should clarify this.
|
|
|
4aca6e |
|
|
|
4aca6e |
CC: Phil Sutter <phil@nwl.cc>
|
|
|
4aca6e |
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
|
|
|
4aca6e |
Acked-by: Phil Sutter <phil@nwl.cc>
|
|
|
4aca6e |
|
|
|
4aca6e |
Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
|
|
|
4aca6e |
---
|
|
|
4aca6e |
devlink/devlink.c | 17 ++++++++---------
|
|
|
4aca6e |
1 file changed, 8 insertions(+), 9 deletions(-)
|
|
|
4aca6e |
|
|
|
4aca6e |
diff --git a/devlink/devlink.c b/devlink/devlink.c
|
|
|
4aca6e |
index 52fc7f49f51c..07c28eb95270 100644
|
|
|
4aca6e |
--- a/devlink/devlink.c
|
|
|
4aca6e |
+++ b/devlink/devlink.c
|
|
|
4aca6e |
@@ -514,19 +514,18 @@ static int dl_argv_handle_port(struct dl *dl, char **p_bus_name,
|
|
|
4aca6e |
return -EINVAL;
|
|
|
4aca6e |
}
|
|
|
4aca6e |
slash_count = strslashcount(str);
|
|
|
4aca6e |
- if (slash_count != 2 && slash_count != 0) {
|
|
|
4aca6e |
+ switch (slash_count) {
|
|
|
4aca6e |
+ case 0:
|
|
|
4aca6e |
+ return __dl_argv_handle_port_ifname(dl, str, p_bus_name,
|
|
|
4aca6e |
+ p_dev_name, p_port_index);
|
|
|
4aca6e |
+ case 2:
|
|
|
4aca6e |
+ return __dl_argv_handle_port(str, p_bus_name,
|
|
|
4aca6e |
+ p_dev_name, p_port_index);
|
|
|
4aca6e |
+ default:
|
|
|
4aca6e |
pr_err("Wrong port identification string format.\n");
|
|
|
4aca6e |
pr_err("Expected \"bus_name/dev_name/port_index\" or \"netdev_ifname\".\n");
|
|
|
4aca6e |
return -EINVAL;
|
|
|
4aca6e |
}
|
|
|
4aca6e |
- if (slash_count == 2) {
|
|
|
4aca6e |
- return __dl_argv_handle_port(str, p_bus_name,
|
|
|
4aca6e |
- p_dev_name, p_port_index);
|
|
|
4aca6e |
- } else if (slash_count == 0) {
|
|
|
4aca6e |
- return __dl_argv_handle_port_ifname(dl, str, p_bus_name,
|
|
|
4aca6e |
- p_dev_name, p_port_index);
|
|
|
4aca6e |
- }
|
|
|
4aca6e |
- return 0;
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
static int dl_argv_handle_both(struct dl *dl, char **p_bus_name,
|
|
|
4aca6e |
--
|
|
|
4aca6e |
2.13.1
|
|
|
4aca6e |
|