netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.5.72] mark assert error cases in skbuff unlikely
@ 2003-06-19 19:24 Stephen Hemminger
  2003-06-19 19:37 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2003-06-19 19:24 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

skbuff.h includes a number of checks for error conditions which can be optimized
by the compiler.  Use BUG_ON where possible.

--- include/linux/skbuff.h.orig	2003-06-19 12:10:27.000000000 -0700
+++ include/linux/skbuff.h	2003-06-19 11:44:43.000000000 -0700
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2.5.72] mark assert error cases in skbuff unlikely
  2003-06-19 19:24 [PATCH 2.5.72] mark assert error cases in skbuff unlikely Stephen Hemminger
@ 2003-06-19 19:37 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2003-06-19 19:37 UTC (permalink / raw)
  To: shemminger; +Cc: netdev

   From: Stephen Hemminger <shemminger@osdl.org>
   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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-06-19 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-19 19:24 [PATCH 2.5.72] mark assert error cases in skbuff unlikely Stephen Hemminger
2003-06-19 19:37 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).