Skip to content

Commit

Permalink
net: convert BUG_TRAP to generic WARN_ON
Browse files Browse the repository at this point in the history
Removes legacy reinvent-the-wheel type thing. The generic
machinery integrates much better to automated debugging aids
such as kerneloops.org (and others), and is unambiguous due to
better naming. Non-intuively BUG_TRAP() is actually equal to
WARN_ON() rather than BUG_ON() though some might actually be
promoted to BUG_ON() but I left that to future.

I could make at least one BUILD_BUG_ON conversion.

Signed-off-by: Ilpo Järvinen <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ij1 authored and davem330 committed Jul 26, 2008
1 parent 53e5e96 commit 547b792
Show file tree
Hide file tree
Showing 51 changed files with 159 additions and 155 deletions.
5 changes: 3 additions & 2 deletions include/net/request_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/bug.h>

#include <net/sock.h>

Expand Down Expand Up @@ -170,7 +171,7 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue
{
struct request_sock *req = queue->rskq_accept_head;

BUG_TRAP(req != NULL);
WARN_ON(req == NULL);

queue->rskq_accept_head = req->dl_next;
if (queue->rskq_accept_head == NULL)
Expand All @@ -185,7 +186,7 @@ static inline struct sock *reqsk_queue_get_child(struct request_sock_queue *queu
struct request_sock *req = reqsk_queue_remove(queue);
struct sock *child = req->sk;

BUG_TRAP(child != NULL);
WARN_ON(child == NULL);

sk_acceptq_removed(parent);
__reqsk_free(req);
Expand Down
4 changes: 2 additions & 2 deletions net/appletalk/ddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + skb_shinfo(skb)->frags[i].size;
if ((copy = end - offset) > 0) {
Expand All @@ -986,7 +986,7 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
for (; list; list = list->next) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
if ((copy = end - offset) > 0) {
Expand Down
8 changes: 4 additions & 4 deletions net/core/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset,
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + skb_shinfo(skb)->frags[i].size;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -315,7 +315,7 @@ int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset,
for (; list; list = list->next) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -366,7 +366,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + skb_shinfo(skb)->frags[i].size;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -402,7 +402,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
for (; list; list=list->next) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
if ((copy = end - offset) > 0) {
Expand Down
10 changes: 5 additions & 5 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ static void net_tx_action(struct softirq_action *h)
struct sk_buff *skb = clist;
clist = clist->next;

BUG_TRAP(!atomic_read(&skb->users));
WARN_ON(atomic_read(&skb->users));
__kfree_skb(skb);
}
}
Expand Down Expand Up @@ -3847,7 +3847,7 @@ static void rollback_registered(struct net_device *dev)
dev->uninit(dev);

/* Notifier chain MUST detach us from master device. */
BUG_TRAP(!dev->master);
WARN_ON(dev->master);

/* Remove entries from kobject tree */
netdev_unregister_kobject(dev);
Expand Down Expand Up @@ -4169,9 +4169,9 @@ void netdev_run_todo(void)

/* paranoia */
BUG_ON(atomic_read(&dev->refcnt));
BUG_TRAP(!dev->ip_ptr);
BUG_TRAP(!dev->ip6_ptr);
BUG_TRAP(!dev->dn_ptr);
WARN_ON(dev->ip_ptr);
WARN_ON(dev->ip6_ptr);
WARN_ON(dev->dn_ptr);

if (dev->destructor)
dev->destructor(dev);
Expand Down
2 changes: 1 addition & 1 deletion net/core/request_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
}
}

BUG_TRAP(lopt->qlen == 0);
WARN_ON(lopt->qlen != 0);
if (lopt_size > PAGE_SIZE)
vfree(lopt);
else
Expand Down
20 changes: 10 additions & 10 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + skb_shinfo(skb)->frags[i].size;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -1229,7 +1229,7 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
for (; list; list = list->next) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -1475,7 +1475,7 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + frag->size;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -1503,7 +1503,7 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
for (; list; list = list->next) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -1552,7 +1552,7 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + skb_shinfo(skb)->frags[i].size;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -1581,7 +1581,7 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
for (; list; list = list->next) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -1629,7 +1629,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + skb_shinfo(skb)->frags[i].size;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -1662,7 +1662,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
__wsum csum2;
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
if ((copy = end - offset) > 0) {
Expand Down Expand Up @@ -2373,7 +2373,7 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + skb_shinfo(skb)->frags[i].size;
if ((copy = end - offset) > 0) {
Expand All @@ -2397,7 +2397,7 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
for (; list; list = list->next) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
if ((copy = end - offset) > 0) {
Expand Down
6 changes: 3 additions & 3 deletions net/core/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ void sk_stream_kill_queues(struct sock *sk)
__skb_queue_purge(&sk->sk_error_queue);

/* Next, the write queue. */
BUG_TRAP(skb_queue_empty(&sk->sk_write_queue));
WARN_ON(!skb_queue_empty(&sk->sk_write_queue));

/* Account for returned memory. */
sk_mem_reclaim(sk);

BUG_TRAP(!sk->sk_wmem_queued);
BUG_TRAP(!sk->sk_forward_alloc);
WARN_ON(sk->sk_wmem_queued);
WARN_ON(sk->sk_forward_alloc);

/* It is _impossible_ for the backlog to contain anything
* when we get here. All user references to this socket
Expand Down
5 changes: 2 additions & 3 deletions net/core/user_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#include <linux/dmaengine.h>
#include <linux/socket.h>
#include <linux/rtnetlink.h> /* for BUG_TRAP */
#include <net/tcp.h>
#include <net/netdma.h>

Expand Down Expand Up @@ -71,7 +70,7 @@ int dma_skb_copy_datagram_iovec(struct dma_chan *chan,
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + skb_shinfo(skb)->frags[i].size;
copy = end - offset;
Expand Down Expand Up @@ -100,7 +99,7 @@ int dma_skb_copy_datagram_iovec(struct dma_chan *chan,
for (; list; list = list->next) {
int end;

BUG_TRAP(start <= offset + len);
WARN_ON(start > offset + len);

end = start + list->len;
copy = end - offset;
Expand Down
2 changes: 1 addition & 1 deletion net/dccp/dccp.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static inline bool dccp_loss_free(const u64 s1, const u64 s2, const u64 ndp)
{
s64 delta = dccp_delta_seqno(s1, s2);

BUG_TRAP(delta >= 0);
WARN_ON(delta < 0);
return (u64)delta <= ndp + 1;
}

Expand Down
2 changes: 1 addition & 1 deletion net/dccp/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,

/* Stop the REQUEST timer */
inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS);
BUG_TRAP(sk->sk_send_head != NULL);
WARN_ON(sk->sk_send_head == NULL);
__kfree_skb(sk->sk_send_head);
sk->sk_send_head = NULL;

Expand Down
2 changes: 1 addition & 1 deletion net/dccp/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
* ICMPs are not backlogged, hence we cannot get an established
* socket here.
*/
BUG_TRAP(!req->sk);
WARN_ON(req->sk);

if (seq != dccp_rsk(req)->dreq_iss) {
NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
Expand Down
2 changes: 1 addition & 1 deletion net/dccp/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
* ICMPs are not backlogged, hence we cannot get an established
* socket here.
*/
BUG_TRAP(req->sk == NULL);
WARN_ON(req->sk != NULL);

if (seq != dccp_rsk(req)->dreq_iss) {
NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
Expand Down
4 changes: 2 additions & 2 deletions net/dccp/proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ int dccp_disconnect(struct sock *sk, int flags)
inet_csk_delack_init(sk);
__sk_dst_reset(sk);

BUG_TRAP(!inet->num || icsk->icsk_bind_hash);
WARN_ON(inet->num && !icsk->icsk_bind_hash);

sk->sk_error_report(sk);
return err;
Expand Down Expand Up @@ -981,7 +981,7 @@ void dccp_close(struct sock *sk, long timeout)
*/
local_bh_disable();
bh_lock_sock(sk);
BUG_TRAP(!sock_owned_by_user(sk));
WARN_ON(sock_owned_by_user(sk));

/* Have we already been destroyed by a softirq or backlog? */
if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED)
Expand Down
2 changes: 1 addition & 1 deletion net/dccp/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void dccp_retransmit_timer(struct sock *sk)
* -- Acks in client-PARTOPEN state (sec. 8.1.5)
* -- CloseReq in server-CLOSEREQ state (sec. 8.3)
* -- Close in node-CLOSING state (sec. 8.3) */
BUG_TRAP(sk->sk_send_head != NULL);
WARN_ON(sk->sk_send_head == NULL);

/*
* More than than 4MSL (8 minutes) has passed, a RESET(aborted) was
Expand Down
14 changes: 7 additions & 7 deletions net/ipv4/af_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ void inet_sock_destruct(struct sock *sk)
return;
}

BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc));
BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc));
BUG_TRAP(!sk->sk_wmem_queued);
BUG_TRAP(!sk->sk_forward_alloc);
WARN_ON(atomic_read(&sk->sk_rmem_alloc));
WARN_ON(atomic_read(&sk->sk_wmem_alloc));
WARN_ON(sk->sk_wmem_queued);
WARN_ON(sk->sk_forward_alloc);

kfree(inet->opt);
dst_release(sk->sk_dst_cache);
Expand Down Expand Up @@ -341,7 +341,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol)
answer_flags = answer->flags;
rcu_read_unlock();

BUG_TRAP(answer_prot->slab != NULL);
WARN_ON(answer_prot->slab == NULL);

err = -ENOBUFS;
sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot);
Expand Down Expand Up @@ -661,8 +661,8 @@ int inet_accept(struct socket *sock, struct socket *newsock, int flags)

lock_sock(sk2);

BUG_TRAP((1 << sk2->sk_state) &
(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_CLOSE));
WARN_ON(!((1 << sk2->sk_state) &
(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_CLOSE)));

sock_graft(sk2, newsock);

Expand Down
6 changes: 3 additions & 3 deletions net/ipv4/devinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ void in_dev_finish_destroy(struct in_device *idev)
{
struct net_device *dev = idev->dev;

BUG_TRAP(!idev->ifa_list);
BUG_TRAP(!idev->mc_list);
WARN_ON(idev->ifa_list);
WARN_ON(idev->mc_list);
#ifdef NET_REFCNT_DEBUG
printk(KERN_DEBUG "in_dev_finish_destroy: %p=%s\n",
idev, dev ? dev->name : "NIL");
Expand Down Expand Up @@ -399,7 +399,7 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
}
ipv4_devconf_setall(in_dev);
if (ifa->ifa_dev != in_dev) {
BUG_TRAP(!ifa->ifa_dev);
WARN_ON(ifa->ifa_dev);
in_dev_hold(in_dev);
ifa->ifa_dev = in_dev;
}
Expand Down
Loading

0 comments on commit 547b792

Please sign in to comment.