diff options
author | Ying Xue <ying.xue@windriver.com> | 2013-10-18 01:23:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-18 13:20:43 -0400 |
commit | 636c0371a737c27510df867161fb8100c2f086bd (patch) | |
tree | 8112f958eeab13d16c07212ddb8bf6e264d47777 | |
parent | 679815834857d5305dae108a03addccf16d86868 (diff) |
tipc: correct return value of link_cmd_set_value routine
link_cmd_set_value() takes commands for link, bearer and media related
configuration. Genereally the function returns 0 when a command is
recognized, and -EINVAL when it is not. However, in the switch for link
related commands it returns 0 even when the command is unrecognized. This
will sometimes make it look as if a failed configuration command has been
successful, but has otherwise no negative effects.
We remove this anomaly by returning -EINVAL even for link commands. We also
rework all three switches to make them conforming to common kernel coding
style.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/tipc/link.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index be73a1fa7c65..223bbc87e451 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -2641,6 +2641,7 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
2641 | struct tipc_link *l_ptr; | 2641 | struct tipc_link *l_ptr; |
2642 | struct tipc_bearer *b_ptr; | 2642 | struct tipc_bearer *b_ptr; |
2643 | struct tipc_media *m_ptr; | 2643 | struct tipc_media *m_ptr; |
2644 | int res = 0; | ||
2644 | 2645 | ||
2645 | l_ptr = link_find_link(name, &node); | 2646 | l_ptr = link_find_link(name, &node); |
2646 | if (l_ptr) { | 2647 | if (l_ptr) { |
@@ -2663,9 +2664,12 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
2663 | case TIPC_CMD_SET_LINK_WINDOW: | 2664 | case TIPC_CMD_SET_LINK_WINDOW: |
2664 | tipc_link_set_queue_limits(l_ptr, new_value); | 2665 | tipc_link_set_queue_limits(l_ptr, new_value); |
2665 | break; | 2666 | break; |
2667 | default: | ||
2668 | res = -EINVAL; | ||
2669 | break; | ||
2666 | } | 2670 | } |
2667 | tipc_node_unlock(node); | 2671 | tipc_node_unlock(node); |
2668 | return 0; | 2672 | return res; |
2669 | } | 2673 | } |
2670 | 2674 | ||
2671 | b_ptr = tipc_bearer_find(name); | 2675 | b_ptr = tipc_bearer_find(name); |
@@ -2673,15 +2677,18 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
2673 | switch (cmd) { | 2677 | switch (cmd) { |
2674 | case TIPC_CMD_SET_LINK_TOL: | 2678 | case TIPC_CMD_SET_LINK_TOL: |
2675 | b_ptr->tolerance = new_value; | 2679 | b_ptr->tolerance = new_value; |
2676 | return 0; | 2680 | break; |
2677 | case TIPC_CMD_SET_LINK_PRI: | 2681 | case TIPC_CMD_SET_LINK_PRI: |
2678 | b_ptr->priority = new_value; | 2682 | b_ptr->priority = new_value; |
2679 | return 0; | 2683 | break; |
2680 | case TIPC_CMD_SET_LINK_WINDOW: | 2684 | case TIPC_CMD_SET_LINK_WINDOW: |
2681 | b_ptr->window = new_value; | 2685 | b_ptr->window = new_value; |
2682 | return 0; | 2686 | break; |
2687 | default: | ||
2688 | res = -EINVAL; | ||
2689 | break; | ||
2683 | } | 2690 | } |
2684 | return -EINVAL; | 2691 | return res; |
2685 | } | 2692 | } |
2686 | 2693 | ||
2687 | m_ptr = tipc_media_find(name); | 2694 | m_ptr = tipc_media_find(name); |
@@ -2690,15 +2697,18 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
2690 | switch (cmd) { | 2697 | switch (cmd) { |
2691 | case TIPC_CMD_SET_LINK_TOL: | 2698 | case TIPC_CMD_SET_LINK_TOL: |
2692 | m_ptr->tolerance = new_value; | 2699 | m_ptr->tolerance = new_value; |
2693 | return 0; | 2700 | break; |
2694 | case TIPC_CMD_SET_LINK_PRI: | 2701 | case TIPC_CMD_SET_LINK_PRI: |
2695 | m_ptr->priority = new_value; | 2702 | m_ptr->priority = new_value; |
2696 | return 0; | 2703 | break; |
2697 | case TIPC_CMD_SET_LINK_WINDOW: | 2704 | case TIPC_CMD_SET_LINK_WINDOW: |
2698 | m_ptr->window = new_value; | 2705 | m_ptr->window = new_value; |
2699 | return 0; | 2706 | break; |
2707 | default: | ||
2708 | res = -EINVAL; | ||
2709 | break; | ||
2700 | } | 2710 | } |
2701 | return -EINVAL; | 2711 | return res; |
2702 | } | 2712 | } |
2703 | 2713 | ||
2704 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, | 2714 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, |