Commit cd228d54 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

[PPP]: Remove ptr comparisons to 0

fix sparse warnings "Using plain integer as NULL pointer"
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dbb2ed24
...@@ -160,7 +160,7 @@ ppp_asynctty_open(struct tty_struct *tty) ...@@ -160,7 +160,7 @@ ppp_asynctty_open(struct tty_struct *tty)
err = -ENOMEM; err = -ENOMEM;
ap = kzalloc(sizeof(*ap), GFP_KERNEL); ap = kzalloc(sizeof(*ap), GFP_KERNEL);
if (ap == 0) if (!ap)
goto out; goto out;
/* initialize the asyncppp structure */ /* initialize the asyncppp structure */
...@@ -215,7 +215,7 @@ ppp_asynctty_close(struct tty_struct *tty) ...@@ -215,7 +215,7 @@ ppp_asynctty_close(struct tty_struct *tty)
ap = tty->disc_data; ap = tty->disc_data;
tty->disc_data = NULL; tty->disc_data = NULL;
write_unlock_irq(&disc_data_lock); write_unlock_irq(&disc_data_lock);
if (ap == 0) if (!ap)
return; return;
/* /*
...@@ -230,10 +230,10 @@ ppp_asynctty_close(struct tty_struct *tty) ...@@ -230,10 +230,10 @@ ppp_asynctty_close(struct tty_struct *tty)
tasklet_kill(&ap->tsk); tasklet_kill(&ap->tsk);
ppp_unregister_channel(&ap->chan); ppp_unregister_channel(&ap->chan);
if (ap->rpkt != 0) if (ap->rpkt)
kfree_skb(ap->rpkt); kfree_skb(ap->rpkt);
skb_queue_purge(&ap->rqueue); skb_queue_purge(&ap->rqueue);
if (ap->tpkt != 0) if (ap->tpkt)
kfree_skb(ap->tpkt); kfree_skb(ap->tpkt);
kfree(ap); kfree(ap);
} }
...@@ -285,13 +285,13 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, ...@@ -285,13 +285,13 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
int err, val; int err, val;
int __user *p = (int __user *)arg; int __user *p = (int __user *)arg;
if (ap == 0) if (!ap)
return -ENXIO; return -ENXIO;
err = -EFAULT; err = -EFAULT;
switch (cmd) { switch (cmd) {
case PPPIOCGCHAN: case PPPIOCGCHAN:
err = -ENXIO; err = -ENXIO;
if (ap == 0) if (!ap)
break; break;
err = -EFAULT; err = -EFAULT;
if (put_user(ppp_channel_index(&ap->chan), p)) if (put_user(ppp_channel_index(&ap->chan), p))
...@@ -301,7 +301,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, ...@@ -301,7 +301,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
case PPPIOCGUNIT: case PPPIOCGUNIT:
err = -ENXIO; err = -ENXIO;
if (ap == 0) if (!ap)
break; break;
err = -EFAULT; err = -EFAULT;
if (put_user(ppp_unit_number(&ap->chan), p)) if (put_user(ppp_unit_number(&ap->chan), p))
...@@ -350,7 +350,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf, ...@@ -350,7 +350,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
struct asyncppp *ap = ap_get(tty); struct asyncppp *ap = ap_get(tty);
unsigned long flags; unsigned long flags;
if (ap == 0) if (!ap)
return; return;
spin_lock_irqsave(&ap->recv_lock, flags); spin_lock_irqsave(&ap->recv_lock, flags);
ppp_async_input(ap, buf, cflags, count); ppp_async_input(ap, buf, cflags, count);
...@@ -369,7 +369,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty) ...@@ -369,7 +369,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty)
struct asyncppp *ap = ap_get(tty); struct asyncppp *ap = ap_get(tty);
clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
if (ap == 0) if (!ap)
return; return;
set_bit(XMIT_WAKEUP, &ap->xmit_flags); set_bit(XMIT_WAKEUP, &ap->xmit_flags);
tasklet_schedule(&ap->tsk); tasklet_schedule(&ap->tsk);
...@@ -684,7 +684,7 @@ ppp_async_push(struct asyncppp *ap) ...@@ -684,7 +684,7 @@ ppp_async_push(struct asyncppp *ap)
tty_stuffed = 1; tty_stuffed = 1;
continue; continue;
} }
if (ap->optr >= ap->olim && ap->tpkt != 0) { if (ap->optr >= ap->olim && ap->tpkt) {
if (ppp_async_encode(ap)) { if (ppp_async_encode(ap)) {
/* finished processing ap->tpkt */ /* finished processing ap->tpkt */
clear_bit(XMIT_FULL, &ap->xmit_flags); clear_bit(XMIT_FULL, &ap->xmit_flags);
...@@ -704,7 +704,7 @@ ppp_async_push(struct asyncppp *ap) ...@@ -704,7 +704,7 @@ ppp_async_push(struct asyncppp *ap)
clear_bit(XMIT_BUSY, &ap->xmit_flags); clear_bit(XMIT_BUSY, &ap->xmit_flags);
/* any more work to do? if not, exit the loop */ /* any more work to do? if not, exit the loop */
if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags)
|| (!tty_stuffed && ap->tpkt != 0))) || (!tty_stuffed && ap->tpkt)))
break; break;
/* more work to do, see if we can do it now */ /* more work to do, see if we can do it now */
if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags)) if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags))
...@@ -715,7 +715,7 @@ ppp_async_push(struct asyncppp *ap) ...@@ -715,7 +715,7 @@ ppp_async_push(struct asyncppp *ap)
flush: flush:
clear_bit(XMIT_BUSY, &ap->xmit_flags); clear_bit(XMIT_BUSY, &ap->xmit_flags);
if (ap->tpkt != 0) { if (ap->tpkt) {
kfree_skb(ap->tpkt); kfree_skb(ap->tpkt);
ap->tpkt = NULL; ap->tpkt = NULL;
clear_bit(XMIT_FULL, &ap->xmit_flags); clear_bit(XMIT_FULL, &ap->xmit_flags);
...@@ -848,7 +848,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, ...@@ -848,7 +848,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
s = 0; s = 0;
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
c = buf[i]; c = buf[i];
if (flags != 0 && flags[i] != 0) if (flags && flags[i] != 0)
continue; continue;
s |= (c & 0x80)? SC_RCV_B7_1: SC_RCV_B7_0; s |= (c & 0x80)? SC_RCV_B7_1: SC_RCV_B7_0;
c = ((c >> 4) ^ c) & 0xf; c = ((c >> 4) ^ c) & 0xf;
...@@ -865,7 +865,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, ...@@ -865,7 +865,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
n = scan_ordinary(ap, buf, count); n = scan_ordinary(ap, buf, count);
f = 0; f = 0;
if (flags != 0 && (ap->state & SC_TOSS) == 0) { if (flags && (ap->state & SC_TOSS) == 0) {
/* check the flags to see if any char had an error */ /* check the flags to see if any char had an error */
for (j = 0; j < n; ++j) for (j = 0; j < n; ++j)
if ((f = flags[j]) != 0) if ((f = flags[j]) != 0)
...@@ -878,9 +878,9 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, ...@@ -878,9 +878,9 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
} else if (n > 0 && (ap->state & SC_TOSS) == 0) { } else if (n > 0 && (ap->state & SC_TOSS) == 0) {
/* stuff the chars in the skb */ /* stuff the chars in the skb */
skb = ap->rpkt; skb = ap->rpkt;
if (skb == 0) { if (!skb) {
skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2); skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2);
if (skb == 0) if (!skb)
goto nomem; goto nomem;
ap->rpkt = skb; ap->rpkt = skb;
} }
...@@ -927,7 +927,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, ...@@ -927,7 +927,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
++n; ++n;
buf += n; buf += n;
if (flags != 0) if (flags)
flags += n; flags += n;
count -= n; count -= n;
} }
......
This diff is collapsed.
...@@ -209,7 +209,7 @@ ppp_sync_open(struct tty_struct *tty) ...@@ -209,7 +209,7 @@ ppp_sync_open(struct tty_struct *tty)
ap = kzalloc(sizeof(*ap), GFP_KERNEL); ap = kzalloc(sizeof(*ap), GFP_KERNEL);
err = -ENOMEM; err = -ENOMEM;
if (ap == 0) if (!ap)
goto out; goto out;
/* initialize the syncppp structure */ /* initialize the syncppp structure */
...@@ -262,7 +262,7 @@ ppp_sync_close(struct tty_struct *tty) ...@@ -262,7 +262,7 @@ ppp_sync_close(struct tty_struct *tty)
ap = tty->disc_data; ap = tty->disc_data;
tty->disc_data = NULL; tty->disc_data = NULL;
write_unlock_irq(&disc_data_lock); write_unlock_irq(&disc_data_lock);
if (ap == 0) if (!ap)
return; return;
/* /*
...@@ -278,7 +278,7 @@ ppp_sync_close(struct tty_struct *tty) ...@@ -278,7 +278,7 @@ ppp_sync_close(struct tty_struct *tty)
ppp_unregister_channel(&ap->chan); ppp_unregister_channel(&ap->chan);
skb_queue_purge(&ap->rqueue); skb_queue_purge(&ap->rqueue);
if (ap->tpkt != 0) if (ap->tpkt)
kfree_skb(ap->tpkt); kfree_skb(ap->tpkt);
kfree(ap); kfree(ap);
} }
...@@ -325,13 +325,13 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file, ...@@ -325,13 +325,13 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file,
int __user *p = (int __user *)arg; int __user *p = (int __user *)arg;
int err, val; int err, val;
if (ap == 0) if (!ap)
return -ENXIO; return -ENXIO;
err = -EFAULT; err = -EFAULT;
switch (cmd) { switch (cmd) {
case PPPIOCGCHAN: case PPPIOCGCHAN:
err = -ENXIO; err = -ENXIO;
if (ap == 0) if (!ap)
break; break;
err = -EFAULT; err = -EFAULT;
if (put_user(ppp_channel_index(&ap->chan), p)) if (put_user(ppp_channel_index(&ap->chan), p))
...@@ -341,7 +341,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file, ...@@ -341,7 +341,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file,
case PPPIOCGUNIT: case PPPIOCGUNIT:
err = -ENXIO; err = -ENXIO;
if (ap == 0) if (!ap)
break; break;
err = -EFAULT; err = -EFAULT;
if (put_user(ppp_unit_number(&ap->chan), p)) if (put_user(ppp_unit_number(&ap->chan), p))
...@@ -390,7 +390,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, ...@@ -390,7 +390,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
struct syncppp *ap = sp_get(tty); struct syncppp *ap = sp_get(tty);
unsigned long flags; unsigned long flags;
if (ap == 0) if (!ap)
return; return;
spin_lock_irqsave(&ap->recv_lock, flags); spin_lock_irqsave(&ap->recv_lock, flags);
ppp_sync_input(ap, buf, cflags, count); ppp_sync_input(ap, buf, cflags, count);
...@@ -409,7 +409,7 @@ ppp_sync_wakeup(struct tty_struct *tty) ...@@ -409,7 +409,7 @@ ppp_sync_wakeup(struct tty_struct *tty)
struct syncppp *ap = sp_get(tty); struct syncppp *ap = sp_get(tty);
clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
if (ap == 0) if (!ap)
return; return;
set_bit(XMIT_WAKEUP, &ap->xmit_flags); set_bit(XMIT_WAKEUP, &ap->xmit_flags);
tasklet_schedule(&ap->tsk); tasklet_schedule(&ap->tsk);
...@@ -651,7 +651,7 @@ ppp_sync_push(struct syncppp *ap) ...@@ -651,7 +651,7 @@ ppp_sync_push(struct syncppp *ap)
for (;;) { for (;;) {
if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags)) if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags))
tty_stuffed = 0; tty_stuffed = 0;
if (!tty_stuffed && ap->tpkt != 0) { if (!tty_stuffed && ap->tpkt) {
set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len); sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len);
if (sent < 0) if (sent < 0)
...@@ -669,7 +669,7 @@ ppp_sync_push(struct syncppp *ap) ...@@ -669,7 +669,7 @@ ppp_sync_push(struct syncppp *ap)
/* haven't made any progress */ /* haven't made any progress */
spin_unlock_bh(&ap->xmit_lock); spin_unlock_bh(&ap->xmit_lock);
if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags)
|| (!tty_stuffed && ap->tpkt != 0))) || (!tty_stuffed && ap->tpkt)))
break; break;
if (!spin_trylock_bh(&ap->xmit_lock)) if (!spin_trylock_bh(&ap->xmit_lock))
break; break;
...@@ -677,7 +677,7 @@ ppp_sync_push(struct syncppp *ap) ...@@ -677,7 +677,7 @@ ppp_sync_push(struct syncppp *ap)
return done; return done;
flush: flush:
if (ap->tpkt != 0) { if (ap->tpkt) {
kfree_skb(ap->tpkt); kfree_skb(ap->tpkt);
ap->tpkt = NULL; ap->tpkt = NULL;
clear_bit(XMIT_FULL, &ap->xmit_flags); clear_bit(XMIT_FULL, &ap->xmit_flags);
...@@ -732,7 +732,8 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf, ...@@ -732,7 +732,8 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf,
ppp_print_buffer ("receive buffer", buf, count); ppp_print_buffer ("receive buffer", buf, count);
/* stuff the chars in the skb */ /* stuff the chars in the skb */
if ((skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2)) == 0) { skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2);
if (!skb) {
printk(KERN_ERR "PPPsync: no memory (input pkt)\n"); printk(KERN_ERR "PPPsync: no memory (input pkt)\n");
goto err; goto err;
} }
...@@ -740,7 +741,7 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf, ...@@ -740,7 +741,7 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf,
if (buf[0] != PPP_ALLSTATIONS) if (buf[0] != PPP_ALLSTATIONS)
skb_reserve(skb, 2 + (buf[0] & 1)); skb_reserve(skb, 2 + (buf[0] & 1));
if (flags != 0 && *flags) { if (flags && *flags) {
/* error flag set, ignore frame */ /* error flag set, ignore frame */
goto err; goto err;
} else if (count > skb_tailroom(skb)) { } else if (count > skb_tailroom(skb)) {
......
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