ieee802154: cleanup WARN_ON for fc fetch
authorAlexander Aring <aar@pengutronix.de>
Wed, 6 Jul 2016 21:32:30 +0000 (23:32 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 8 Jul 2016 11:23:12 +0000 (13:23 +0200)
This patch cleanups the WARN_ON which occurs when the sk buffer has
insufficient buffer space by moving the WARN_ON into if condition.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/mac802154.h

index bb7bfec..286824a 100644 (file)
@@ -250,11 +250,10 @@ static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
        __le16 fc;
 
        /* check if we can fc at skb_mac_header of sk buffer */
-       if (unlikely(!skb_mac_header_was_set(skb) ||
-                    (skb_tail_pointer(skb) - skb_mac_header(skb)) < 2)) {
-               WARN_ON(1);
+       if (WARN_ON(!skb_mac_header_was_set(skb) ||
+                   (skb_tail_pointer(skb) -
+                    skb_mac_header(skb)) < IEEE802154_FC_LEN))
                return cpu_to_le16(0);
-       }
 
        memcpy(&fc, skb_mac_header(skb), IEEE802154_FC_LEN);
        return fc;