X-GM-THRID: 6329558000960798720 X-Received: by 10.28.193.198 with SMTP id r189mr2126882wmf.2.1473715370128; Mon, 12 Sep 2016 14:22:50 -0700 (PDT) X-BeenThere: outreachy-kernel@googlegroups.com Received: by 10.28.17.7 with SMTP id 7ls1553398wmr.0.canary; Mon, 12 Sep 2016 14:22:49 -0700 (PDT) X-Received: by 10.28.150.135 with SMTP id y129mr1323851wmd.1.1473715369657; Mon, 12 Sep 2016 14:22:49 -0700 (PDT) Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr. [192.134.164.104]) by gmr-mx.google.com with ESMTPS id w134si112624wmf.3.2016.09.12.14.22.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Sep 2016 14:22:49 -0700 (PDT) Received-SPF: neutral (google.com: 192.134.164.104 is neither permitted nor denied by domain of julia.lawall@lip6.fr) client-ip=192.134.164.104; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.134.164.104 is neither permitted nor denied by domain of julia.lawall@lip6.fr) smtp.mailfrom=julia.lawall@lip6.fr X-IronPort-AV: E=Sophos;i="5.30,324,1470693600"; d="scan'208";a="192902424" Received: from 198.67.28.109.rev.sfr.net (HELO hadrien.local) ([109.28.67.198]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Sep 2016 23:22:48 +0200 Date: Mon, 12 Sep 2016 23:22:47 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: sayli karnik cc: outreachy-kernel@googlegroups.com, gregkh@linuxfoundation.org Subject: Re: [Outreachy kernel] [PATCH] staging: ks7010: Remove the explicit NULL comparison In-Reply-To: <20160912211728.GA13970@sayli-HP-15-Notebook-PC> Message-ID: References: <20160912211728.GA13970@sayli-HP-15-Notebook-PC> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 13 Sep 2016, sayli karnik wrote: > The patch removes the explicit null comparisons entirely for the ks7010 driver. > This was detected by checkpatch.pl It's orthogonal to the change you have made here, but there are a lot of ugly casts on the calls to kmalloc. Since kmalloc returns a void * type, its result can be implicitly casted to other types via an assignment. julia > Signed-off-by: sayli karnik > --- > drivers/staging/ks7010/ks7010_sdio.c | 14 +++++++------- > drivers/staging/ks7010/ks_hostif.c | 30 +++++++++++++++--------------- > drivers/staging/ks7010/ks_wlan_net.c | 2 +- > 3 files changed, 23 insertions(+), 23 deletions(-) > > diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c > index b7337fd..129e203 100644 > --- a/drivers/staging/ks7010/ks7010_sdio.c > +++ b/drivers/staging/ks7010/ks7010_sdio.c > @@ -268,7 +268,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, > > if (priv->dev_state < DEVICE_STATE_BOOT) { > kfree(p); > - if (complete_handler != NULL) > + if (complete_handler) > (*complete_handler) (arg1, arg2); > return 1; > } > @@ -277,7 +277,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, > /* in case of buffer overflow */ > DPRINTK(1, "tx buffer overflow\n"); > kfree(p); > - if (complete_handler != NULL) > + if (complete_handler) > (*complete_handler) (arg1, arg2); > return 1; > } > @@ -349,7 +349,7 @@ static void tx_device_task(void *dev) > > } > kfree(sp->sendp); /* allocated memory free */ > - if (sp->complete_handler != NULL) /* TX Complete */ > + if (sp->complete_handler) /* TX Complete */ > (*sp->complete_handler) (sp->arg1, sp->arg2); > inc_txqhead(priv); > > @@ -696,7 +696,7 @@ static void trx_device_exit(struct ks_wlan_private *priv) > while (cnt_txqbody(priv) > 0) { > sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; > kfree(sp->sendp); /* allocated memory free */ > - if (sp->complete_handler != NULL) /* TX Complete */ > + if (sp->complete_handler) /* TX Complete */ > (*sp->complete_handler) (sp->arg1, sp->arg2); > inc_txqhead(priv); > } > @@ -1029,7 +1029,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, > > /* private memory allocate */ > netdev = alloc_etherdev(sizeof(*priv)); > - if (netdev == NULL) { > + if (!netdev) { > printk(KERN_ERR "ks7010 : Unable to alloc new net device\n"); > goto error_release_irq; > } > @@ -1146,7 +1146,7 @@ static void ks7010_sdio_remove(struct sdio_func *func) > > card = sdio_get_drvdata(func); > > - if (card == NULL) > + if (!card) > return; > > DPRINTK(1, "priv = card->priv\n"); > @@ -1168,7 +1168,7 @@ static void ks7010_sdio_remove(struct sdio_func *func) > struct hostif_stop_request_t *pp; > pp = (struct hostif_stop_request_t *) > kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; /* to do goto ni suru */ > } > diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c > index a8822fe..f32ce5a 100644 > --- a/drivers/staging/ks7010/ks_hostif.c > +++ b/drivers/staging/ks7010/ks_hostif.c > @@ -1176,7 +1176,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) > kmalloc(hif_align_size(sizeof(*pp) + 6 + packet_len + 8), > KS_WLAN_MEM_FLAG); > > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > dev_kfree_skb(packet); > return -2; > @@ -1315,7 +1315,7 @@ void hostif_mib_get_request(struct ks_wlan_private *priv, > /* make primitive */ > pp = (struct hostif_mib_get_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1346,7 +1346,7 @@ void hostif_mib_set_request(struct ks_wlan_private *priv, > /* make primitive */ > pp = (struct hostif_mib_set_request_t *) > kmalloc(hif_align_size(sizeof(*pp) + size), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1376,7 +1376,7 @@ void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode) > /* make primitive */ > pp = (struct hostif_start_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1404,7 +1404,7 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) > /* make primitive */ > pp = (struct hostif_ps_adhoc_set_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1448,7 +1448,7 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv) > /* make primitive */ > pp = (struct hostif_infrastructure_set_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1515,7 +1515,7 @@ void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) > /* make primitive */ > pp = (struct hostif_infrastructure_set2_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1585,7 +1585,7 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv) > /* make primitive */ > pp = (struct hostif_adhoc_set_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1631,7 +1631,7 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv) > /* make primitive */ > pp = (struct hostif_adhoc_set2_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1679,7 +1679,7 @@ void hostif_stop_request(struct ks_wlan_private *priv) > /* make primitive */ > pp = (struct hostif_stop_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1702,7 +1702,7 @@ void hostif_phy_information_request(struct ks_wlan_private *priv) > /* make primitive */ > pp = (struct hostif_phy_information_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1734,7 +1734,7 @@ void hostif_power_mngmt_request(struct ks_wlan_private *priv, > /* make primitive */ > pp = (struct hostif_power_mngmt_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1761,7 +1761,7 @@ void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode) > /* make primitive */ > pp = (struct hostif_sleep_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1795,7 +1795,7 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv, > /* make primitive */ > pp = (struct hostif_bss_scan_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > @@ -1852,7 +1852,7 @@ void hostif_mic_failure_request(struct ks_wlan_private *priv, > /* make primitive */ > pp = (struct hostif_mic_failure_request_t *) > kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); > - if (pp == NULL) { > + if (!pp) { > DPRINTK(3, "allocate memory failed..\n"); > return; > } > diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c > index 1e21eb1..8462c98 100644 > --- a/drivers/staging/ks7010/ks_wlan_net.c > +++ b/drivers/staging/ks7010/ks_wlan_net.c > @@ -3366,7 +3366,7 @@ int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) > > DPRINTK(3, "in_interrupt()=%ld\n", in_interrupt()); > > - if (skb == NULL) { > + if (!skb) { > printk(KERN_ERR "ks_wlan: skb == NULL!!!\n"); > return 0; > } > -- > 2.7.4 > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com. > To post to this group, send email to outreachy-kernel@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160912211728.GA13970%40sayli-HP-15-Notebook-PC. > For more options, visit https://groups.google.com/d/optout. >