Remark #593: Variable "x" was set but never used

There are several common cases where code will not be executed.

Example #1: from Linux-2.6-rc3 file net/netlink/af_netlink.c

    741 int netlink_sendskb(struct sock *sk, struct sk_buff *skb, int protocol)
    742 {
    743         struct netlink_sock *nlk;
    744         int len = skb->len;
    746         nlk = nlk_sk(sk);
    748         skb_queue_tail(&sk->sk_receive_queue, skb);
    749         sk->sk_data_ready(sk, len);
    750         sock_put(sk);
    751         return len;
    752 }

nlk is set but used in the above example.

How to resolve:

Removing unneccesary code is usually the preferred course of action.

Caution: should be taken to make sure that the code is not referenced by another architecture or code that is hidden by an #ifdef or other code Logo