[{"id":1769573,"web_url":"http://patchwork.ozlabs.org/comment/1769573/","msgid":"<alpine.DEB.2.20.1709160912540.2943@hadrien>","list_archive_url":null,"date":"2017-09-16T07:14:21","subject":"Re: [Outreachy kernel] [PATCH] Staging: irda: Use !x instead of NULL\n\tcomparison","submitter":{"id":10041,"url":"http://patchwork.ozlabs.org/api/people/10041/","name":"Julia Lawall","email":"julia.lawall@lip6.fr"},"content":"On Sat, 16 Sep 2017, Srishti Sharma wrote:\n\n> Test for NULL as !x where functions that return NULL on failure\n> are used. Done using the following semantic patch by coccinelle.\n>\n> @ is_null @\n> expression E;\n> statement S;\n> @@\n>\n> E = (\\(kmalloc\\|devm_kzalloc\\|kmalloc_array\\|devm_ioremap\\|\n> usb_alloc_urb\\|alloc_netdev\\|dev_alloc_skb\\)(...));\n>\n> (\n> if(!E)\n>    S\n> |\n> -if(E==NULL)\n> +if(!E)\n>     S\n> )\n>\n> Signed-off-by: Srishti Sharma <srishtishar@gmail.com>\n\nAcked-by: Julia Lawall <julia.lawall@lip6.fr>\n\n\n> ---\n>  drivers/staging/irda/net/discovery.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/drivers/staging/irda/net/discovery.c b/drivers/staging/irda/net/discovery.c\n> index 364d70a..1e54954 100644\n> --- a/drivers/staging/irda/net/discovery.c\n> +++ b/drivers/staging/irda/net/discovery.c\n> @@ -179,7 +179,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force)\n>  \t\t\t\t/* Create the client specific buffer */\n>  \t\t\t\tn = HASHBIN_GET_SIZE(log);\n>  \t\t\t\tbuffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC);\n> -\t\t\t\tif (buffer == NULL) {\n> +\t\t\t\tif (!buffer) {\n>  \t\t\t\t\tspin_unlock_irqrestore(&log->hb_spinlock, flags);\n>  \t\t\t\t\treturn;\n>  \t\t\t\t}\n> @@ -291,7 +291,7 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn,\n>  \t\t\t\t/* Create the client specific buffer */\n>  \t\t\t\tn = HASHBIN_GET_SIZE(log);\n>  \t\t\t\tbuffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC);\n> -\t\t\t\tif (buffer == NULL) {\n> +\t\t\t\tif (!buffer) {\n>  \t\t\t\t\tspin_unlock_irqrestore(&log->hb_spinlock, flags);\n>  \t\t\t\t\treturn NULL;\n>  \t\t\t\t}\n> --\n> 2.7.4\n>\n> --\n> You received this message because you are subscribed to the Google Groups \"outreachy-kernel\" group.\n> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.\n> To post to this group, send email to outreachy-kernel@googlegroups.com.\n> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1505543667-4670-1-git-send-email-srishtishar%40gmail.com.\n> For more options, visit https://groups.google.com/d/optout.\n>","headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xvNn95kJXz9t2M\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 17:14:37 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751314AbdIPHOY (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 16 Sep 2017 03:14:24 -0400","from mail2-relais-roc.national.inria.fr ([192.134.164.83]:61835\n\t\"EHLO mail2-relais-roc.national.inria.fr\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1750909AbdIPHOX (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Sat, 16 Sep 2017 03:14:23 -0400","from 85-171-60-79.rev.numericable.fr (HELO [192.168.0.15])\n\t([85.171.60.79]) by mail2-relais-roc.national.inria.fr with\n\tESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Sep 2017 09:14:22 +0200"],"X-IronPort-AV":"E=Sophos;i=\"5.42,400,1500933600\"; d=\"scan'208\";a=\"291359800\"","Date":"Sat, 16 Sep 2017 09:14:21 +0200 (CEST)","From":"Julia Lawall <julia.lawall@lip6.fr>","X-X-Sender":"jll@hadrien","To":"Srishti Sharma <srishtishar@gmail.com>","cc":"samuel@sortiz.org, gregkh@linuxfoundation.org,\n\tnetdev@vger.kernel.org, devel@driverdev.osuosl.org,\n\tlinux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com","Subject":"Re: [Outreachy kernel] [PATCH] Staging: irda: Use !x instead of NULL\n\tcomparison","In-Reply-To":"<1505543667-4670-1-git-send-email-srishtishar@gmail.com>","Message-ID":"<alpine.DEB.2.20.1709160912540.2943@hadrien>","References":"<1505543667-4670-1-git-send-email-srishtishar@gmail.com>","User-Agent":"Alpine 2.20 (DEB 67 2015-01-07)","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"}}]