Commit e2fc8cb4 authored by Joel A. Fowler's avatar Joel A. Fowler Committed by David S. Miller

ctcm: fix minor findings from code analysis tool

From: Ursula Braun <ursula.braun@de.ibm.com>

This patch fixes problems in the ctcm driver identified by
static code analysis:
o remove an unnecessary always true condition in ctcm_unpack_skb
o remove duplicate assignment in ctc_mpc_alloc_channel
o remove an unnecessary always true condition in ctcmpc_send_sweep_resp
o remove duplicate initialization in ctcmpc_unpack_skb
o shorten if condition in mpc_action_go_inop
o remove INOP event if mpc group is undefined in mpc_action_doxid7
Signed-off-by: default avatarJoel A. Fowler <fowlerja@us.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fb8585fc
...@@ -168,11 +168,9 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -168,11 +168,9 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb)
if (len > 0) { if (len > 0) {
skb_pull(pskb, header->length); skb_pull(pskb, header->length);
if (skb_tailroom(pskb) < LL_HEADER_LENGTH) { if (skb_tailroom(pskb) < LL_HEADER_LENGTH) {
if (!(ch->logflags & LOG_FLAG_OVERRUN)) {
CTCM_DBF_DEV_NAME(TRACE, dev, CTCM_DBF_DEV_NAME(TRACE, dev,
"Overrun in ctcm_unpack_skb"); "Overrun in ctcm_unpack_skb");
ch->logflags |= LOG_FLAG_OVERRUN; ch->logflags |= LOG_FLAG_OVERRUN;
}
return; return;
} }
skb_put(pskb, LL_HEADER_LENGTH); skb_put(pskb, LL_HEADER_LENGTH);
......
...@@ -393,7 +393,6 @@ int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int)) ...@@ -393,7 +393,6 @@ int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int))
} else { } else {
/* there are problems...bail out */ /* there are problems...bail out */
/* there may be a state mismatch so restart */ /* there may be a state mismatch so restart */
grp->port_persist = 1;
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
grp->allocchan_callback_retries = 0; grp->allocchan_callback_retries = 0;
} }
...@@ -699,11 +698,9 @@ static void ctcmpc_send_sweep_resp(struct channel *rch) ...@@ -699,11 +698,9 @@ static void ctcmpc_send_sweep_resp(struct channel *rch)
return; return;
done: done:
if (rc != 0) {
grp->in_sweep = 0; grp->in_sweep = 0;
ctcm_clear_busy_do(dev); ctcm_clear_busy_do(dev);
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
}
return; return;
} }
...@@ -1118,7 +1115,6 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1118,7 +1115,6 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
if (unlikely(fsm_getstate(grp->fsm) != MPCG_STATE_READY)) if (unlikely(fsm_getstate(grp->fsm) != MPCG_STATE_READY))
goto done; goto done;
pdu_last_seen = 0;
while ((pskb->len > 0) && !pdu_last_seen) { while ((pskb->len > 0) && !pdu_last_seen) {
curr_pdu = (struct pdu *)pskb->data; curr_pdu = (struct pdu *)pskb->data;
...@@ -1396,8 +1392,7 @@ static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg) ...@@ -1396,8 +1392,7 @@ static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg)
CTCM_FUNTAIL, dev->name); CTCM_FUNTAIL, dev->name);
if ((grp->saved_state != MPCG_STATE_RESET) || if ((grp->saved_state != MPCG_STATE_RESET) ||
/* dealloc_channel has been called */ /* dealloc_channel has been called */
((grp->saved_state == MPCG_STATE_RESET) && (grp->port_persist == 0))
(grp->port_persist == 0)))
fsm_deltimer(&priv->restart_timer); fsm_deltimer(&priv->restart_timer);
wch = priv->channel[WRITE]; wch = priv->channel[WRITE];
...@@ -1917,10 +1912,8 @@ static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg) ...@@ -1917,10 +1912,8 @@ static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg)
if (priv) if (priv)
grp = priv->mpcg; grp = priv->mpcg;
if (grp == NULL) { if (grp == NULL)
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
return; return;
}
for (direction = READ; direction <= WRITE; direction++) { for (direction = READ; direction <= WRITE; direction++) {
struct channel *ch = priv->channel[direction]; struct channel *ch = priv->channel[direction];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment