Skip to content

Commit b03efcf

Browse files
committed
[NET]: Transform skb_queue_len() binary tests into skb_queue_empty()
This is part of the grand scheme to eliminate the qlen member of skb_queue_head, and subsequently remove the 'list' member of sk_buff. Most users of skb_queue_len() want to know if the queue is empty or not, and that's trivially done with skb_queue_empty() which doesn't use the skb_queue_head->qlen member and instead uses the queue list emptyness as the test. Signed-off-by: David S. Miller <[email protected]>
1 parent a92b7b8 commit b03efcf

34 files changed

+84
-89
lines changed

drivers/bluetooth/hci_vhci.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static unsigned int hci_vhci_chr_poll(struct file *file, poll_table * wait)
120120

121121
poll_wait(file, &hci_vhci->read_wait, wait);
122122

123-
if (skb_queue_len(&hci_vhci->readq))
123+
if (!skb_queue_empty(&hci_vhci->readq))
124124
return POLLIN | POLLRDNORM;
125125

126126
return POLLOUT | POLLWRNORM;

drivers/isdn/hisax/isdnl1.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ BChannel_proc_xmt(struct BCState *bcs)
279279
if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags))
280280
st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
281281
if (!test_bit(BC_FLG_ACTIV, &bcs->Flag)) {
282-
if (!test_bit(BC_FLG_BUSY, &bcs->Flag) && (!skb_queue_len(&bcs->squeue))) {
282+
if (!test_bit(BC_FLG_BUSY, &bcs->Flag) &&
283+
skb_queue_empty(&bcs->squeue)) {
283284
st->l2.l2l1(st, PH_DEACTIVATE | CONFIRM, NULL);
284285
}
285286
}

drivers/isdn/hisax/isdnl2.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ static int l2addrsize(struct Layer2 *l2);
108108
static void
109109
set_peer_busy(struct Layer2 *l2) {
110110
test_and_set_bit(FLG_PEER_BUSY, &l2->flag);
111-
if (skb_queue_len(&l2->i_queue) || skb_queue_len(&l2->ui_queue))
111+
if (!skb_queue_empty(&l2->i_queue) ||
112+
!skb_queue_empty(&l2->ui_queue))
112113
test_and_set_bit(FLG_L2BLOCK, &l2->flag);
113114
}
114115

@@ -754,7 +755,7 @@ l2_restart_multi(struct FsmInst *fi, int event, void *arg)
754755
st->l2.l2l3(st, DL_ESTABLISH | INDICATION, NULL);
755756

756757
if ((ST_L2_7==state) || (ST_L2_8 == state))
757-
if (skb_queue_len(&st->l2.i_queue) && cansend(st))
758+
if (!skb_queue_empty(&st->l2.i_queue) && cansend(st))
758759
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
759760
}
760761

@@ -810,7 +811,7 @@ l2_connected(struct FsmInst *fi, int event, void *arg)
810811
if (pr != -1)
811812
st->l2.l2l3(st, pr, NULL);
812813

813-
if (skb_queue_len(&st->l2.i_queue) && cansend(st))
814+
if (!skb_queue_empty(&st->l2.i_queue) && cansend(st))
814815
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
815816
}
816817

@@ -1014,7 +1015,7 @@ l2_st7_got_super(struct FsmInst *fi, int event, void *arg)
10141015
if(typ != RR) FsmDelTimer(&st->l2.t203, 9);
10151016
restart_t200(st, 12);
10161017
}
1017-
if (skb_queue_len(&st->l2.i_queue) && (typ == RR))
1018+
if (!skb_queue_empty(&st->l2.i_queue) && (typ == RR))
10181019
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
10191020
} else
10201021
nrerrorrecovery(fi);
@@ -1120,7 +1121,7 @@ l2_got_iframe(struct FsmInst *fi, int event, void *arg)
11201121
return;
11211122
}
11221123

1123-
if (skb_queue_len(&st->l2.i_queue) && (fi->state == ST_L2_7))
1124+
if (!skb_queue_empty(&st->l2.i_queue) && (fi->state == ST_L2_7))
11241125
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
11251126
if (test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag))
11261127
enquiry_cr(st, RR, RSP, 0);
@@ -1138,7 +1139,7 @@ l2_got_tei(struct FsmInst *fi, int event, void *arg)
11381139
test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
11391140
} else
11401141
FsmChangeState(fi, ST_L2_4);
1141-
if (skb_queue_len(&st->l2.ui_queue))
1142+
if (!skb_queue_empty(&st->l2.ui_queue))
11421143
tx_ui(st);
11431144
}
11441145

@@ -1301,7 +1302,7 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
13011302
FsmDelTimer(&st->l2.t203, 13);
13021303
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 11);
13031304
}
1304-
if (skb_queue_len(&l2->i_queue) && cansend(st))
1305+
if (!skb_queue_empty(&l2->i_queue) && cansend(st))
13051306
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
13061307
}
13071308

@@ -1347,7 +1348,7 @@ l2_st8_got_super(struct FsmInst *fi, int event, void *arg)
13471348
}
13481349
invoke_retransmission(st, nr);
13491350
FsmChangeState(fi, ST_L2_7);
1350-
if (skb_queue_len(&l2->i_queue) && cansend(st))
1351+
if (!skb_queue_empty(&l2->i_queue) && cansend(st))
13511352
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
13521353
} else
13531354
nrerrorrecovery(fi);

drivers/isdn/hisax/isdnl3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ release_l3_process(struct l3_process *p)
302302
!test_bit(FLG_PTP, &p->st->l2.flag)) {
303303
if (p->debug)
304304
l3_debug(p->st, "release_l3_process: last process");
305-
if (!skb_queue_len(&p->st->l3.squeue)) {
305+
if (skb_queue_empty(&p->st->l3.squeue)) {
306306
if (p->debug)
307307
l3_debug(p->st, "release_l3_process: release link");
308308
if (p->st->protocol != ISDN_PTYPE_NI1)

drivers/isdn/i4l/isdn_tty.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count)
12231223
total += c;
12241224
}
12251225
atomic_dec(&info->xmit_lock);
1226-
if ((info->xmit_count) || (skb_queue_len(&info->xmit_queue))) {
1226+
if ((info->xmit_count) || !skb_queue_empty(&info->xmit_queue)) {
12271227
if (m->mdmreg[REG_DXMT] & BIT_DXMT) {
12281228
isdn_tty_senddown(info);
12291229
isdn_tty_tint(info);
@@ -1284,7 +1284,7 @@ isdn_tty_flush_chars(struct tty_struct *tty)
12841284

12851285
if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_flush_chars"))
12861286
return;
1287-
if ((info->xmit_count) || (skb_queue_len(&info->xmit_queue)))
1287+
if ((info->xmit_count) || !skb_queue_empty(&info->xmit_queue))
12881288
isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, 1);
12891289
}
12901290

drivers/isdn/icn/icn.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ icn_pollbchan_send(int channel, icn_card * card)
304304
isdn_ctrl cmd;
305305

306306
if (!(card->sndcount[channel] || card->xskb[channel] ||
307-
skb_queue_len(&card->spqueue[channel])))
307+
!skb_queue_empty(&card->spqueue[channel])))
308308
return;
309309
if (icn_trymaplock_channel(card, mch)) {
310310
while (sbfree &&
311311
(card->sndcount[channel] ||
312-
skb_queue_len(&card->spqueue[channel]) ||
312+
!skb_queue_empty(&card->spqueue[channel]) ||
313313
card->xskb[channel])) {
314314
spin_lock_irqsave(&card->lock, flags);
315315
if (card->xmit_lock[channel]) {

drivers/net/hamradio/scc.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static inline void scc_discard_buffers(struct scc_channel *scc)
304304
scc->tx_buff = NULL;
305305
}
306306

307-
while (skb_queue_len(&scc->tx_queue))
307+
while (!skb_queue_empty(&scc->tx_queue))
308308
dev_kfree_skb(skb_dequeue(&scc->tx_queue));
309309

310310
spin_unlock_irqrestore(&scc->lock, flags);
@@ -1126,8 +1126,7 @@ static void t_dwait(unsigned long channel)
11261126

11271127
if (scc->stat.tx_state == TXS_WAIT) /* maxkeyup or idle timeout */
11281128
{
1129-
if (skb_queue_len(&scc->tx_queue) == 0) /* nothing to send */
1130-
{
1129+
if (skb_queue_empty(&scc->tx_queue)) { /* nothing to send */
11311130
scc->stat.tx_state = TXS_IDLE;
11321131
netif_wake_queue(scc->dev); /* t_maxkeyup locked it. */
11331132
return;

drivers/net/ppp_async.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
364364
spin_lock_irqsave(&ap->recv_lock, flags);
365365
ppp_async_input(ap, buf, cflags, count);
366366
spin_unlock_irqrestore(&ap->recv_lock, flags);
367-
if (skb_queue_len(&ap->rqueue))
367+
if (!skb_queue_empty(&ap->rqueue))
368368
tasklet_schedule(&ap->tsk);
369369
ap_put(ap);
370370
if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)

drivers/net/ppp_generic.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
12371237
pch = list_entry(list, struct channel, clist);
12381238
navail += pch->avail = (pch->chan != NULL);
12391239
if (pch->avail) {
1240-
if (skb_queue_len(&pch->file.xq) == 0
1241-
|| !pch->had_frag) {
1240+
if (skb_queue_empty(&pch->file.xq) ||
1241+
!pch->had_frag) {
12421242
pch->avail = 2;
12431243
++nfree;
12441244
}
@@ -1374,8 +1374,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
13741374

13751375
/* try to send it down the channel */
13761376
chan = pch->chan;
1377-
if (skb_queue_len(&pch->file.xq)
1378-
|| !chan->ops->start_xmit(chan, frag))
1377+
if (!skb_queue_empty(&pch->file.xq) ||
1378+
!chan->ops->start_xmit(chan, frag))
13791379
skb_queue_tail(&pch->file.xq, frag);
13801380
pch->had_frag = 1;
13811381
p += flen;
@@ -1412,7 +1412,7 @@ ppp_channel_push(struct channel *pch)
14121412

14131413
spin_lock_bh(&pch->downl);
14141414
if (pch->chan != 0) {
1415-
while (skb_queue_len(&pch->file.xq) > 0) {
1415+
while (!skb_queue_empty(&pch->file.xq)) {
14161416
skb = skb_dequeue(&pch->file.xq);
14171417
if (!pch->chan->ops->start_xmit(pch->chan, skb)) {
14181418
/* put the packet back and try again later */
@@ -1426,7 +1426,7 @@ ppp_channel_push(struct channel *pch)
14261426
}
14271427
spin_unlock_bh(&pch->downl);
14281428
/* see if there is anything from the attached unit to be sent */
1429-
if (skb_queue_len(&pch->file.xq) == 0) {
1429+
if (skb_queue_empty(&pch->file.xq)) {
14301430
read_lock_bh(&pch->upl);
14311431
ppp = pch->ppp;
14321432
if (ppp != 0)

drivers/net/ppp_synctty.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
406406
spin_lock_irqsave(&ap->recv_lock, flags);
407407
ppp_sync_input(ap, buf, cflags, count);
408408
spin_unlock_irqrestore(&ap->recv_lock, flags);
409-
if (skb_queue_len(&ap->rqueue))
409+
if (!skb_queue_empty(&ap->rqueue))
410410
tasklet_schedule(&ap->tsk);
411411
sp_put(ap);
412412
if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)

drivers/net/tun.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static unsigned int tun_chr_poll(struct file *file, poll_table * wait)
215215

216216
poll_wait(file, &tun->read_wait, wait);
217217

218-
if (skb_queue_len(&tun->readq))
218+
if (!skb_queue_empty(&tun->readq))
219219
mask |= POLLIN | POLLRDNORM;
220220

221221
return mask;

drivers/net/wireless/airo.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
23742374
/*
23752375
* Clean out tx queue
23762376
*/
2377-
if (test_bit(FLAG_MPI, &ai->flags) && skb_queue_len (&ai->txq) > 0) {
2377+
if (test_bit(FLAG_MPI, &ai->flags) && !skb_queue_empty(&ai->txq)) {
23782378
struct sk_buff *skb = NULL;
23792379
for (;(skb = skb_dequeue(&ai->txq));)
23802380
dev_kfree_skb(skb);
@@ -3287,7 +3287,7 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
32873287
if (status & EV_TXEXC)
32883288
get_tx_error(apriv, -1);
32893289
spin_lock_irqsave(&apriv->aux_lock, flags);
3290-
if (skb_queue_len (&apriv->txq)) {
3290+
if (!skb_queue_empty(&apriv->txq)) {
32913291
spin_unlock_irqrestore(&apriv->aux_lock,flags);
32923292
mpi_send_packet (dev);
32933293
} else {

drivers/s390/net/claw.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ claw_pack_skb(struct claw_privbk *privptr)
428428
new_skb = NULL; /* assume no dice */
429429
pkt_cnt = 0;
430430
CLAW_DBF_TEXT(4,trace,"PackSKBe");
431-
if (skb_queue_len(&p_ch->collect_queue) > 0) {
431+
if (!skb_queue_empty(&p_ch->collect_queue)) {
432432
/* some data */
433433
held_skb = skb_dequeue(&p_ch->collect_queue);
434434
if (p_env->packing != DO_PACKED)
@@ -1254,7 +1254,7 @@ claw_write_next ( struct chbk * p_ch )
12541254
privptr = (struct claw_privbk *) dev->priv;
12551255
claw_free_wrt_buf( dev );
12561256
if ((privptr->write_free_count > 0) &&
1257-
(skb_queue_len(&p_ch->collect_queue) > 0)) {
1257+
!skb_queue_empty(&p_ch->collect_queue)) {
12581258
pk_skb = claw_pack_skb(privptr);
12591259
while (pk_skb != NULL) {
12601260
rc = claw_hw_tx( pk_skb, dev,1);

drivers/s390/net/ctctty.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ ctc_tty_readmodem(ctc_tty_info *info)
156156
skb_queue_head(&info->rx_queue, skb);
157157
else {
158158
kfree_skb(skb);
159-
ret = skb_queue_len(&info->rx_queue);
159+
ret = !skb_queue_empty(&info->rx_queue);
160160
}
161161
}
162162
}
@@ -530,7 +530,7 @@ ctc_tty_write(struct tty_struct *tty, const u_char * buf, int count)
530530
total += c;
531531
count -= c;
532532
}
533-
if (skb_queue_len(&info->tx_queue)) {
533+
if (!skb_queue_empty(&info->tx_queue)) {
534534
info->lsr &= ~UART_LSR_TEMT;
535535
tasklet_schedule(&info->tasklet);
536536
}
@@ -594,7 +594,7 @@ ctc_tty_flush_chars(struct tty_struct *tty)
594594
return;
595595
if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_flush_chars"))
596596
return;
597-
if (tty->stopped || tty->hw_stopped || (!skb_queue_len(&info->tx_queue)))
597+
if (tty->stopped || tty->hw_stopped || skb_queue_empty(&info->tx_queue))
598598
return;
599599
tasklet_schedule(&info->tasklet);
600600
}

drivers/usb/net/usbnet.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3227,9 +3227,9 @@ static int usbnet_stop (struct net_device *net)
32273227
temp = unlink_urbs (dev, &dev->txq) + unlink_urbs (dev, &dev->rxq);
32283228

32293229
// maybe wait for deletions to finish.
3230-
while (skb_queue_len (&dev->rxq)
3231-
&& skb_queue_len (&dev->txq)
3232-
&& skb_queue_len (&dev->done)) {
3230+
while (!skb_queue_empty(&dev->rxq) &&
3231+
!skb_queue_empty(&dev->txq) &&
3232+
!skb_queue_empty(&dev->done)) {
32333233
msleep(UNLINK_TIMEOUT_MS);
32343234
if (netif_msg_ifdown (dev))
32353235
devdbg (dev, "waited for %d urb completions", temp);

include/net/irda/irda_device.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ int irda_device_is_receiving(struct net_device *dev);
224224
/* Interface for internal use */
225225
static inline int irda_device_txqueue_empty(const struct net_device *dev)
226226
{
227-
return (skb_queue_len(&dev->qdisc->q) == 0);
227+
return skb_queue_empty(&dev->qdisc->q);
228228
}
229229
int irda_device_set_raw_mode(struct net_device* self, int status);
230230
struct net_device *alloc_irdadev(int sizeof_priv);

include/net/tcp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ static __inline__ void tcp_fast_path_on(struct tcp_sock *tp)
991991

992992
static inline void tcp_fast_path_check(struct sock *sk, struct tcp_sock *tp)
993993
{
994-
if (skb_queue_len(&tp->out_of_order_queue) == 0 &&
994+
if (skb_queue_empty(&tp->out_of_order_queue) &&
995995
tp->rcv_wnd &&
996996
atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf &&
997997
!tp->urg_data)

net/bluetooth/cmtp/core.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static int cmtp_send_frame(struct cmtp_session *session, unsigned char *data, in
213213
return kernel_sendmsg(sock, &msg, &iv, 1, len);
214214
}
215215

216-
static int cmtp_process_transmit(struct cmtp_session *session)
216+
static void cmtp_process_transmit(struct cmtp_session *session)
217217
{
218218
struct sk_buff *skb, *nskb;
219219
unsigned char *hdr;
@@ -223,7 +223,7 @@ static int cmtp_process_transmit(struct cmtp_session *session)
223223

224224
if (!(nskb = alloc_skb(session->mtu, GFP_ATOMIC))) {
225225
BT_ERR("Can't allocate memory for new frame");
226-
return -ENOMEM;
226+
return;
227227
}
228228

229229
while ((skb = skb_dequeue(&session->transmit))) {
@@ -275,8 +275,6 @@ static int cmtp_process_transmit(struct cmtp_session *session)
275275
cmtp_send_frame(session, nskb->data, nskb->len);
276276

277277
kfree_skb(nskb);
278-
279-
return skb_queue_len(&session->transmit);
280278
}
281279

282280
static int cmtp_session(void *arg)

net/bluetooth/hidp/core.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static int hidp_send_frame(struct socket *sock, unsigned char *data, int len)
428428
return kernel_sendmsg(sock, &msg, &iv, 1, len);
429429
}
430430

431-
static int hidp_process_transmit(struct hidp_session *session)
431+
static void hidp_process_transmit(struct hidp_session *session)
432432
{
433433
struct sk_buff *skb;
434434

@@ -453,9 +453,6 @@ static int hidp_process_transmit(struct hidp_session *session)
453453
hidp_set_timer(session);
454454
kfree_skb(skb);
455455
}
456-
457-
return skb_queue_len(&session->ctrl_transmit) +
458-
skb_queue_len(&session->intr_transmit);
459456
}
460457

461458
static int hidp_session(void *arg)

net/bluetooth/rfcomm/sock.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,11 @@ static long rfcomm_sock_data_wait(struct sock *sk, long timeo)
590590
for (;;) {
591591
set_current_state(TASK_INTERRUPTIBLE);
592592

593-
if (skb_queue_len(&sk->sk_receive_queue) || sk->sk_err || (sk->sk_shutdown & RCV_SHUTDOWN) ||
594-
signal_pending(current) || !timeo)
593+
if (!skb_queue_empty(&sk->sk_receive_queue) ||
594+
sk->sk_err ||
595+
(sk->sk_shutdown & RCV_SHUTDOWN) ||
596+
signal_pending(current) ||
597+
!timeo)
595598
break;
596599

597600
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);

net/bluetooth/rfcomm/tty.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty)
781781

782782
BT_DBG("tty %p dev %p", tty, dev);
783783

784-
if (skb_queue_len(&dlc->tx_queue))
784+
if (!skb_queue_empty(&dlc->tx_queue))
785785
return dlc->mtu;
786786

787787
return 0;

0 commit comments

Comments
 (0)