mark assert error cases in skbuff unlikely
Subsystems (2)
PATCH 1/1 mark assert error cases in skbuff unlikely
skbuff.h includes a number of checks for error conditions which can be optimized by the compiler. Use BUG_ON where possible.
linux/skbuff.h renamed from linux/skbuff.h.orig +7 -12
@@ -802,12 +802,9 @@skb_shinfo (skb)->nr_frags = i+1 ; } -#define SKB_PAGE_ASSERT (skb) do { if (skb_shinfo(skb)->nr_frags) \ - BUG(); } while (0) -#define SKB_FRAG_ASSERT (skb) do { if (skb_shinfo(skb)->frag_list) \ - BUG(); } while (0) -#define SKB_LINEAR_ASSERT (skb) do { if (skb_is_nonlinear(skb)) \ - BUG(); } while (0) +#define SKB_PAGE_ASSERT (skb) BUG_ON(skb_shinfo(skb)->nr_frags) +#define SKB_FRAG_ASSERT (skb) BUG_ON(skb_shinfo(skb)->frag_list) +#define SKB_LINEAR_ASSERT (skb) BUG_ON(skb_is_nonlinear(skb))/* * Add data to an sk_buff
@@ -836,7 +833,7 @@SKB_LINEAR_ASSERT (skb); skb->tail += len; skb->len += len; -if (skb->tail>skb->end) +if (unlikely (skb->tail>skb->end))skb_over_panic (skb, len,current_text_addr ());return tmp; }
@@ -861,7 +858,7 @@ { skb->data -= len; skb->len += len; -if (skb->data<skb->head) +if (unlikely (skb->data<skb->head))skb_under_panic (skb, len,current_text_addr ());return skb->data; }
@@ -869,8 +866,7 @@static inline char *__skb_pull (struct sk_buff *skb,unsigned int len) { skb->len -= len; -if (skb->len < skb->data_len) -BUG (); +BUG_ON (skb->len < skb->data_len);return skb->data += len; }
@@ -1132,8 +1128,7 @@static inline void *kmap_skb_frag (const skb_frag_t *frag) {#ifdef CONFIG_HIGHMEM -if (in_irq ()) -BUG (); +BUG_ON (in_irq ());local_bh_disable ();#endif
David S. Miller
Applied From: Stephen Hemminger <[email protected]>
Date: Thu, 19 Jun 2003 12:24:33 -0700
skbuff.h includes a number of checks for error conditions which can be optimized by the compiler. Use BUG_ON where possible.
Applied, thanks.