Subject: kfree_skb: unnecessary check ?

From: Patrick McHardy <[email-masked]>
Date: Wed, 19 Jun 2002 18:53:18 +0200

Hi everyone.

In skbuff.h one sees:

static inline void kfree_skb(struct sk_buff *skb)
{
        if (atomic_read(&skb->users) == 1 || 
atomic_dec_and_test(&skb->users))
                __kfree_skb(skb);
}

Is atomic_dec_and_test really necessary ? atomic_dec_and_test only 
returns true if its argument has hit zero, so it was 1 before.
If atomic_dec is only a bit cheaper than atomic_dec_and_test (which i 
guess it is), wouldn't it make more sense to use something like this:

static inline void kfree_skb(struct sk_buff *skb)
{
    if (atomic_read(&skb->users) == 1)
        __kfree(skb);
    else
        atomic_dec(&skb->users);
}

Bye,
Patrick