netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: "David S. Miller" <davem@redhat.com>
Cc: netdev@oss.sgi.com
Subject: [PATCH 2.5.72] mark assert error cases in skbuff unlikely
Date: Thu, 19 Jun 2003 12:24:33 -0700	[thread overview]
Message-ID: <20030619122433.2dc720ec.shemminger@osdl.org> (raw)

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

             reply	other threads:[~2003-06-19 19:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-19 19:24 Stephen Hemminger [this message]
2003-06-19 19:37 ` [PATCH 2.5.72] mark assert error cases in skbuff unlikely David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030619122433.2dc720ec.shemminger@osdl.org \
    --to=shemminger@osdl.org \
    --cc=davem@redhat.com \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).