[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1470137600-15560-1-git-send-email-mayhs11saini@gmail.com>
Date: Tue, 2 Aug 2016 17:03:20 +0530
From: shyam saini <mayhs11saini@...il.com>
To: gregkh@...uxfoundation.org
Cc: arnd@...db.de, devel@...verdev.osuosl.org, isdn@...ux-pingi.de,
linux-kernel@...r.kernel.org, shyam saini <mayhs11saini@...il.com>
Subject: [PATCH 1651/1651] staging: i4l: pcbit: Remove explicit NULL comparison
Remove the explicit NULL comparison and rewrite in a compact form using Coccinelle
Signed-off-by: shyam saini <mayhs11saini@...il.com>
---
drivers/staging/i4l/pcbit/callbacks.c | 4 ++--
drivers/staging/i4l/pcbit/capi.c | 18 +++++++++---------
drivers/staging/i4l/pcbit/drv.c | 14 +++++++-------
drivers/staging/i4l/pcbit/layer2.c | 9 ++++-----
4 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/i4l/pcbit/callbacks.c b/drivers/staging/i4l/pcbit/callbacks.c
index efb6d6a..41a95a5 100644
--- a/drivers/staging/i4l/pcbit/callbacks.c
+++ b/drivers/staging/i4l/pcbit/callbacks.c
@@ -144,14 +144,14 @@ void cb_in_1(struct pcbit_dev *dev, struct pcbit_chan *chan,
* ictl.num >= strlen() + strlen() + 5
*/
- if (cbdata->data.setup.CallingPN == NULL) {
+ if (!cbdata->data.setup.CallingPN) {
printk(KERN_DEBUG "NULL CallingPN to phone; using 0\n");
strcpy(ictl.parm.setup.phone, "0");
}
else {
strcpy(ictl.parm.setup.phone, cbdata->data.setup.CallingPN);
}
- if (cbdata->data.setup.CalledPN == NULL) {
+ if (!cbdata->data.setup.CalledPN) {
printk(KERN_DEBUG "NULL CalledPN to eazmsn; using 0\n");
strcpy(ictl.parm.setup.eazmsn, "0");
}
diff --git a/drivers/staging/i4l/pcbit/capi.c b/drivers/staging/i4l/pcbit/capi.c
index 4e3cbf8..b11895cb 100644
--- a/drivers/staging/i4l/pcbit/capi.c
+++ b/drivers/staging/i4l/pcbit/capi.c
@@ -76,7 +76,7 @@ int capi_conn_req(const char *calledPN, struct sk_buff **skb, int proto)
if (proto == ISDN_PROTO_L2_TRANS)
len++;
- if ((*skb = dev_alloc_skb(len)) == NULL) {
+ if (!(*skb = dev_alloc_skb(len))) {
printk(KERN_WARNING "capi_conn_req: alloc_skb failed\n");
return -1;
@@ -134,7 +134,7 @@ int capi_conn_req(const char *calledPN, struct sk_buff **skb, int proto)
int capi_conn_resp(struct pcbit_chan *chan, struct sk_buff **skb)
{
- if ((*skb = dev_alloc_skb(5)) == NULL) {
+ if (!(*skb = dev_alloc_skb(5))) {
printk(KERN_WARNING "capi_conn_resp: alloc_skb failed\n");
return -1;
@@ -154,7 +154,7 @@ int capi_conn_active_req(struct pcbit_chan *chan, struct sk_buff **skb)
* 8 bytes
*/
- if ((*skb = dev_alloc_skb(8)) == NULL) {
+ if (!(*skb = dev_alloc_skb(8))) {
printk(KERN_WARNING "capi_conn_active_req: alloc_skb failed\n");
return -1;
@@ -182,7 +182,7 @@ int capi_conn_active_resp(struct pcbit_chan *chan, struct sk_buff **skb)
* 2 bytes
*/
- if ((*skb = dev_alloc_skb(2)) == NULL) {
+ if (!(*skb = dev_alloc_skb(2))) {
printk(KERN_WARNING "capi_conn_active_resp: alloc_skb failed\n");
return -1;
@@ -202,7 +202,7 @@ int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb,
* 18 bytes
*/
- if ((*skb = dev_alloc_skb(18)) == NULL) {
+ if (!(*skb = dev_alloc_skb(18))) {
printk(KERN_WARNING "capi_select_proto_req: alloc_skb failed\n");
return -1;
@@ -263,7 +263,7 @@ int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb,
int capi_activate_transp_req(struct pcbit_chan *chan, struct sk_buff **skb)
{
- if ((*skb = dev_alloc_skb(7)) == NULL) {
+ if (!(*skb = dev_alloc_skb(7))) {
printk(KERN_WARNING "capi_activate_transp_req: alloc_skb failed\n");
return -1;
@@ -321,7 +321,7 @@ int capi_tdata_req(struct pcbit_chan *chan, struct sk_buff *skb)
int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff **skb)
{
- if ((*skb = dev_alloc_skb(4)) == NULL) {
+ if (!(*skb = dev_alloc_skb(4))) {
printk(KERN_WARNING "capi_tdata_resp: alloc_skb failed\n");
return -1;
@@ -338,7 +338,7 @@ int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff **skb)
int capi_disc_req(ushort callref, struct sk_buff **skb, u_char cause)
{
- if ((*skb = dev_alloc_skb(6)) == NULL) {
+ if (!(*skb = dev_alloc_skb(6))) {
printk(KERN_WARNING "capi_disc_req: alloc_skb failed\n");
return -1;
@@ -361,7 +361,7 @@ int capi_disc_req(ushort callref, struct sk_buff **skb, u_char cause)
int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb)
{
- if ((*skb = dev_alloc_skb(2)) == NULL) {
+ if (!(*skb = dev_alloc_skb(2))) {
printk(KERN_WARNING "capi_disc_resp: alloc_skb failed\n");
return -1;
diff --git a/drivers/staging/i4l/pcbit/drv.c b/drivers/staging/i4l/pcbit/drv.c
index c5270e2..62a41d7 100644
--- a/drivers/staging/i4l/pcbit/drv.c
+++ b/drivers/staging/i4l/pcbit/drv.c
@@ -73,7 +73,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
struct pcbit_dev *dev;
isdn_if *dev_if;
- if ((dev = kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL)
+ if (!(dev = kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)))
{
printk("pcbit_init: couldn't malloc pcbit_dev struct\n");
return -ENOMEM;
@@ -306,7 +306,7 @@ static void pcbit_block_timer(unsigned long data)
dev = chan2dev(chan);
- if (dev == NULL) {
+ if (!dev) {
printk(KERN_DEBUG "pcbit: chan2dev failed\n");
return;
}
@@ -333,7 +333,7 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb)
struct pcbit_dev *dev;
dev = finddev(driver);
- if (dev == NULL)
+ if (!dev)
{
printk("finddev returned NULL");
return -1;
@@ -358,7 +358,7 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb)
* see net/core/dev.c
*/
#ifdef BLOCK_TIMER
- if (chan->block_timer.function == NULL) {
+ if (!chan->block_timer.function) {
init_timer(&chan->block_timer);
chan->block_timer.function = &pcbit_block_timer;
chan->block_timer.data = (long) chan;
@@ -422,7 +422,7 @@ static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int cha
/* this is the hard part */
/* dumb board */
/* get it into kernel space */
- if ((ptr = kmalloc(len, GFP_KERNEL)) == NULL)
+ if (!(ptr = kmalloc(len, GFP_KERNEL)))
return -ENOMEM;
if (copy_from_user(ptr, buf, len)) {
kfree(ptr);
@@ -1048,7 +1048,7 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list)
#ifdef DEBUG
printk(KERN_DEBUG "msn: %s\n", ptr->msn);
#endif
- if (dev->msn_list == NULL)
+ if (!dev->msn_list)
dev->msn_list = ptr;
else
back->next = ptr;
@@ -1066,7 +1066,7 @@ static int pcbit_check_msn(struct pcbit_dev *dev, char *msn)
for (ptr = dev->msn_list; ptr; ptr = ptr->next) {
- if (ptr->msn == NULL)
+ if (!ptr->msn)
return 1;
if (strcmp(ptr->msn, msn) == 0)
diff --git a/drivers/staging/i4l/pcbit/layer2.c b/drivers/staging/i4l/pcbit/layer2.c
index 46e1240..6af0dbe 100644
--- a/drivers/staging/i4l/pcbit/layer2.c
+++ b/drivers/staging/i4l/pcbit/layer2.c
@@ -83,8 +83,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum,
dev_kfree_skb(skb);
return -1;
}
- if ((frame = kmalloc(sizeof(struct frame_buf),
- GFP_ATOMIC)) == NULL) {
+ if (!(frame = kmalloc(sizeof(struct frame_buf), GFP_ATOMIC))) {
dev_kfree_skb(skb);
return -1;
}
@@ -104,7 +103,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum,
spin_lock_irqsave(&dev->lock, flags);
- if (dev->write_queue == NULL) {
+ if (!dev->write_queue) {
dev->write_queue = frame;
spin_unlock_irqrestore(&dev->lock, flags);
pcbit_transmit(dev);
@@ -252,7 +251,7 @@ pcbit_transmit(struct pcbit_dev *dev)
spin_lock_irqsave(&dev->lock, flags);
- if (frame->skb == NULL || frame->copied == frame->skb->len) {
+ if (!frame->skb || frame->copied == frame->skb->len) {
dev->write_queue = frame->next;
@@ -352,7 +351,7 @@ pcbit_receive(struct pcbit_dev *dev)
}
frame = kzalloc(sizeof(struct frame_buf), GFP_ATOMIC);
- if (frame == NULL) {
+ if (!frame) {
printk(KERN_WARNING "kmalloc failed\n");
return;
}
--
2.7.4
Powered by blists - more mailing lists