Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1442297ybb; Thu, 26 Mar 2020 00:25:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtrKbgIbDySziU5tTrRORCzoLKTF4nayvnftm35FcY8VeMl1fueL7fGIARcdEGA/gt6eQOT X-Received: by 2002:a9d:18f:: with SMTP id e15mr4960376ote.42.1585207536411; Thu, 26 Mar 2020 00:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585207536; cv=none; d=google.com; s=arc-20160816; b=Zf3AYxFkr0yQ5VT5G3SRtsbcn9MRYDwKQixhzxk3QbUQK6Vu6jFLnM0yC17JoKHwlJ mF7E4wNyO0PkhXW3QWXFgraZI7X5p6QKovFUx5b4xR1OR3dpIujar4XxkHw76eFh67WU Txd8RP635ZWUb8Q5P/ix1Rb8m0AzjP/NQjqSDn1c0NibEyeSJxtTJnxtAOlKt7URsBcZ j4pm75IiYawKq2zkvWpLZrLLcJTUzv9UTMGH00OEvZS3CSTrmXmy1N3iikt/0U6nYbkH GBmWWOT0oDOUx0LWkZm3J3ERYmSSDoXnxfol/40fJ8c4OtTKUI22PyqSzc77KGDvoX+0 3b6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=3Lf0+0VHgh35TDAf3HIKspC6uZePwofg9+LXjg8EnLM=; b=SShy6XFf/Wx0NvpT1wPRGxtrWmG2PXFTZmN8JnEc0o8IRSD8hHrUEXTZjd2pAJF17y nrF85gNITZemDNp7vl6LOntOQXSOq+CfRD+NwGB/QPY0VWxERD9ikZt7UUAsDjViH8O/ NwntxS8pITNcFQeq2Ohc+oY1GU/Z3tmS35aKEoV3D2JHv7xQJaLa7e/s3EkoYMZFK7lZ fe9phpR3mFNSrnTYooovtWvZ6I4qaK/RMpRmoEz7AjtX4fjxTm1wIjKJy/hq+Kwk9XWa ArihTS+0d8jQo3F48o0iZ/8/84G2qztCga6irAl6Jj1xI/unosqPKLwxgv9QaSqWjTde d9ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y65si701951oie.92.2020.03.26.00.25.24; Thu, 26 Mar 2020 00:25:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726590AbgCZHXh (ORCPT + 99 others); Thu, 26 Mar 2020 03:23:37 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:61316 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbgCZHXh (ORCPT ); Thu, 26 Mar 2020 03:23:37 -0400 X-IronPort-AV: E=Sophos;i="5.72,307,1580770800"; d="scan'208";a="343773967" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2020 08:23:35 +0100 Date: Thu, 26 Mar 2020 08:23:34 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Simran Singhal cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, outreachy-kernel Subject: Re: [Outreachy kernel] [PATCH] staging: rtl8723bs: Clean up tests if NULL returned on failure In-Reply-To: <20200325222908.GA5370@simran-Inspiron-5558> Message-ID: References: <20200325222908.GA5370@simran-Inspiron-5558> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Mar 2020, Simran Singhal wrote: > Some functions like kmalloc/kzalloc return NULL on failure. > When NULL represents failure, !x is commonly used. Try for a shorter subject line. "Simplify NULL tests" would do. Then the log message should be in the imperative. julia > > This was done using Coccinelle: > @@ > expression *e; > identifier l1; > @@ > > e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...); > ... > - e == NULL > + !e > > Signed-off-by: Simran Singhal > --- > drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c > index 29f36cca3972..5c27c11f006a 100644 > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c > @@ -474,7 +474,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, > wep_key_len = wep_key_len <= 5 ? 5 : 13; > wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); > pwep = kzalloc(wep_total_len, GFP_KERNEL); > - if (pwep == NULL) { > + if (!pwep) { > RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); > goto exit; > } > @@ -2137,7 +2137,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, > > param_len = sizeof(struct ieee_param) + pext->key_len; > param = kzalloc(param_len, GFP_KERNEL); > - if (param == NULL) > + if (!param) > return -1; > > param->cmd = IEEE_CMD_SET_ENCRYPTION; > @@ -3491,7 +3491,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, > wep_key_len = wep_key_len <= 5 ? 5 : 13; > wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); > pwep = kzalloc(wep_total_len, GFP_KERNEL); > - if (pwep == NULL) { > + if (!pwep) { > DBG_871X(" r871x_set_encryption: pwep allocate fail !!!\n"); > goto exit; > } > -- > 2.17.1 > > -- > 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 view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20200325222908.GA5370%40simran-Inspiron-5558. >