Skip to content

Commit

Permalink
tipc: fix a loop style problem
Browse files Browse the repository at this point in the history
In commit 7d33939
("tipc: delay delete of link when failover is needed") we
introduced a loop for finding and removing a link pointer
in an array. The removal is done after we have left the loop,
giving the impression that one may remove the wrong pointer
if no matching element is found.

This is not really a bug, since we know that there will always
be a matching element, but it looks wrong, and causes a smatch
warning.

We fix this loop with this commit.

Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jon Paul Maloy authored and David S. Miller committed Feb 17, 2014
1 parent 6dd3c9e commit 074bb43
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/tipc/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
int i;

for (i = 0; i < MAX_BEARERS; i++) {
if (l_ptr == n_ptr->links[i])
break;
if (l_ptr != n_ptr->links[i])
continue;
n_ptr->links[i] = NULL;
atomic_dec(&tipc_num_links);
n_ptr->link_cnt--;
}
n_ptr->links[i] = NULL;
atomic_dec(&tipc_num_links);
n_ptr->link_cnt--;
}

static void node_established_contact(struct tipc_node *n_ptr)
Expand Down

0 comments on commit 074bb43

Please sign in to comment.