Commit 09a62660 authored by Kris Katterjohn's avatar Kris Katterjohn Committed by David S. Miller

[NET]: Change some "if (x) BUG();" to "BUG_ON(x);"

This changes some simple "if (x) BUG();" statements to "BUG_ON(x);"
Signed-off-by: default avatarKris Katterjohn <kjak@users.sourceforge.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4bba3925
...@@ -1092,15 +1092,12 @@ int skb_checksum_help(struct sk_buff *skb, int inward) ...@@ -1092,15 +1092,12 @@ int skb_checksum_help(struct sk_buff *skb, int inward)
goto out; goto out;
} }
if (offset > (int)skb->len) BUG_ON(offset > (int)skb->len);
BUG();
csum = skb_checksum(skb, offset, skb->len-offset, 0); csum = skb_checksum(skb, offset, skb->len-offset, 0);
offset = skb->tail - skb->h.raw; offset = skb->tail - skb->h.raw;
if (offset <= 0) BUG_ON(offset <= 0);
BUG(); BUG_ON(skb->csum + 2 > offset);
if (skb->csum + 2 > offset)
BUG();
*(u16*)(skb->h.raw + skb->csum) = csum_fold(csum); *(u16*)(skb->h.raw + skb->csum) = csum_fold(csum);
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
......
...@@ -791,8 +791,7 @@ int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc) ...@@ -791,8 +791,7 @@ int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc)
int end = offset + skb_shinfo(skb)->frags[i].size; int end = offset + skb_shinfo(skb)->frags[i].size;
if (end > len) { if (end > len) {
if (skb_cloned(skb)) { if (skb_cloned(skb)) {
if (!realloc) BUG_ON(!realloc);
BUG();
if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
return -ENOMEM; return -ENOMEM;
} }
...@@ -894,8 +893,7 @@ unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta) ...@@ -894,8 +893,7 @@ unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta)
struct sk_buff *insp = NULL; struct sk_buff *insp = NULL;
do { do {
if (!list) BUG_ON(!list);
BUG();
if (list->len <= eat) { if (list->len <= eat) {
/* Eaten as whole. */ /* Eaten as whole. */
...@@ -1199,8 +1197,7 @@ unsigned int skb_checksum(const struct sk_buff *skb, int offset, ...@@ -1199,8 +1197,7 @@ unsigned int skb_checksum(const struct sk_buff *skb, int offset,
start = end; start = end;
} }
} }
if (len) BUG_ON(len);
BUG();
return csum; return csum;
} }
...@@ -1282,8 +1279,7 @@ unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, ...@@ -1282,8 +1279,7 @@ unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
start = end; start = end;
} }
} }
if (len) BUG_ON(len);
BUG();
return csum; return csum;
} }
...@@ -1297,8 +1293,7 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to) ...@@ -1297,8 +1293,7 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
else else
csstart = skb_headlen(skb); csstart = skb_headlen(skb);
if (csstart > skb_headlen(skb)) BUG_ON(csstart > skb_headlen(skb));
BUG();
memcpy(to, skb->data, csstart); memcpy(to, skb->data, csstart);
......
...@@ -899,8 +899,7 @@ static void icmp_address_reply(struct sk_buff *skb) ...@@ -899,8 +899,7 @@ static void icmp_address_reply(struct sk_buff *skb)
u32 _mask, *mp; u32 _mask, *mp;
mp = skb_header_pointer(skb, 0, sizeof(_mask), &_mask); mp = skb_header_pointer(skb, 0, sizeof(_mask), &_mask);
if (mp == NULL) BUG_ON(mp == NULL);
BUG();
for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
if (*mp == ifa->ifa_mask && if (*mp == ifa->ifa_mask &&
inet_ifa_match(rt->rt_src, ifa)) inet_ifa_match(rt->rt_src, ifa))
......
...@@ -304,8 +304,7 @@ static void unlink_from_pool(struct inet_peer *p) ...@@ -304,8 +304,7 @@ static void unlink_from_pool(struct inet_peer *p)
/* look for a node to insert instead of p */ /* look for a node to insert instead of p */
struct inet_peer *t; struct inet_peer *t;
t = lookup_rightempty(p); t = lookup_rightempty(p);
if (*stackptr[-1] != t) BUG_ON(*stackptr[-1] != t);
BUG();
**--stackptr = t->avl_left; **--stackptr = t->avl_left;
/* t is removed, t->v4daddr > x->v4daddr for any /* t is removed, t->v4daddr > x->v4daddr for any
* x in p->avl_left subtree. * x in p->avl_left subtree.
...@@ -314,8 +313,7 @@ static void unlink_from_pool(struct inet_peer *p) ...@@ -314,8 +313,7 @@ static void unlink_from_pool(struct inet_peer *p)
t->avl_left = p->avl_left; t->avl_left = p->avl_left;
t->avl_right = p->avl_right; t->avl_right = p->avl_right;
t->avl_height = p->avl_height; t->avl_height = p->avl_height;
if (delp[1] != &p->avl_left) BUG_ON(delp[1] != &p->avl_left);
BUG();
delp[1] = &t->avl_left; /* was &p->avl_left */ delp[1] = &t->avl_left; /* was &p->avl_left */
} }
peer_avl_rebalance(stack, stackptr); peer_avl_rebalance(stack, stackptr);
......
...@@ -3347,7 +3347,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, ...@@ -3347,7 +3347,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list,
int offset = start - TCP_SKB_CB(skb)->seq; int offset = start - TCP_SKB_CB(skb)->seq;
int size = TCP_SKB_CB(skb)->end_seq - start; int size = TCP_SKB_CB(skb)->end_seq - start;
if (offset < 0) BUG(); BUG_ON(offset < 0);
if (size > 0) { if (size > 0) {
size = min(copy, size); size = min(copy, size);
if (skb_copy_bits(skb, offset, skb_put(nskb, size), size)) if (skb_copy_bits(skb, offset, skb_put(nskb, size), size))
......
...@@ -297,8 +297,7 @@ static int pfkey_error(struct sadb_msg *orig, int err, struct sock *sk) ...@@ -297,8 +297,7 @@ static int pfkey_error(struct sadb_msg *orig, int err, struct sock *sk)
err = EINTR; err = EINTR;
if (err >= 512) if (err >= 512)
err = EINVAL; err = EINVAL;
if (err <= 0 || err >= 256) BUG_ON(err <= 0 || err >= 256);
BUG();
hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg));
pfkey_hdr_dup(hdr, orig); pfkey_hdr_dup(hdr, orig);
......
...@@ -1250,8 +1250,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, ...@@ -1250,8 +1250,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
case SCTP_CMD_TIMER_START: case SCTP_CMD_TIMER_START:
timer = &asoc->timers[cmd->obj.to]; timer = &asoc->timers[cmd->obj.to];
timeout = asoc->timeouts[cmd->obj.to]; timeout = asoc->timeouts[cmd->obj.to];
if (!timeout) BUG_ON(!timeout);
BUG();
timer->expires = jiffies + timeout; timer->expires = jiffies + timeout;
sctp_association_hold(asoc); sctp_association_hold(asoc);
......
...@@ -575,12 +575,11 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) ...@@ -575,12 +575,11 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
if (rp->q.list.next == &cd->queue) { if (rp->q.list.next == &cd->queue) {
spin_unlock(&queue_lock); spin_unlock(&queue_lock);
up(&queue_io_sem); up(&queue_io_sem);
if (rp->offset) BUG_ON(rp->offset);
BUG();
return 0; return 0;
} }
rq = container_of(rp->q.list.next, struct cache_request, q.list); rq = container_of(rp->q.list.next, struct cache_request, q.list);
if (rq->q.reader) BUG(); BUG_ON(rq->q.reader);
if (rp->offset == 0) if (rp->offset == 0)
rq->readers++; rq->readers++;
spin_unlock(&queue_lock); spin_unlock(&queue_lock);
......
...@@ -122,8 +122,7 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size) ...@@ -122,8 +122,7 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size)
rqstp->rq_argused = 0; rqstp->rq_argused = 0;
rqstp->rq_resused = 0; rqstp->rq_resused = 0;
arghi = 0; arghi = 0;
if (pages > RPCSVC_MAXPAGES) BUG_ON(pages > RPCSVC_MAXPAGES);
BUG();
while (pages) { while (pages) {
struct page *p = alloc_page(GFP_KERNEL); struct page *p = alloc_page(GFP_KERNEL);
if (!p) if (!p)
......
...@@ -540,8 +540,7 @@ void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm, ...@@ -540,8 +540,7 @@ void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm,
start = end; start = end;
} }
} }
if (len) BUG_ON(len);
BUG();
} }
EXPORT_SYMBOL_GPL(skb_icv_walk); EXPORT_SYMBOL_GPL(skb_icv_walk);
...@@ -610,8 +609,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) ...@@ -610,8 +609,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
start = end; start = end;
} }
} }
if (len) BUG_ON(len);
BUG();
return elt; return elt;
} }
EXPORT_SYMBOL_GPL(skb_to_sgvec); EXPORT_SYMBOL_GPL(skb_to_sgvec);
......
...@@ -248,11 +248,9 @@ EXPORT_SYMBOL(xfrm_policy_alloc); ...@@ -248,11 +248,9 @@ EXPORT_SYMBOL(xfrm_policy_alloc);
void __xfrm_policy_destroy(struct xfrm_policy *policy) void __xfrm_policy_destroy(struct xfrm_policy *policy)
{ {
if (!policy->dead) BUG_ON(!policy->dead);
BUG();
if (policy->bundles) BUG_ON(policy->bundles);
BUG();
if (del_timer(&policy->timer)) if (del_timer(&policy->timer))
BUG(); BUG();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment