Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1677978pxy; Fri, 23 Apr 2021 14:12:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0oEn9g6BZ9PEwbkvXQjk+8/lbWVHRVum/MseMn/lCsed6E80hA3uVYNIsdcvyRPXE/N0c X-Received: by 2002:aa7:c789:: with SMTP id n9mr6881056eds.352.1619212338225; Fri, 23 Apr 2021 14:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619212338; cv=none; d=google.com; s=arc-20160816; b=mDCYkCnZSUjHqtk6353hzxs5gOykoCT5GMyLdfvtQJKclLPrkQz0AMnd7FsX4lWor3 jd0q2+WnbxjbSd/cMsW4pXnTn3BPue2nS/le9LwgDwResounRjiuyCY5QafIAMNC7BV5 iIEpro+Ra8mD//8xVMpCKo5jXNVmGZ8tXW8Ko5/I8fVU5tBrQ25vwMfLfep9RPiLp0cp dZBB+0NikPS4UgThuT2xmFhg/NADfvCkLWNEmniGEAEyohvJiLqPvGOIx0cWnT5BwKdq vOmAd7zoPBmyEmlsQrEAFFDdsK+XhxH6IEd/9pma6eDKXFizE5aZpAUHr2fZdtCug6DN nWxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=A22TFll9Blm6PfGJntS755LasWSXUim+ApdH7q9KXpA=; b=d0oBYNEmdzlQJ/Waz23/eer1R6j8LWaDQTs1fTZ9axsIeMf6nplnmbGBz/8NpgUtFR NuBGTYzCKvtUbJ3zqYyjYM1IA3OcR0zF4x1GVdhM3a3dQsdJBMha6kOBBSJt4s1036pw GQXcE/yzZtCqu8ySpmy9WFBab6d/zneTlNoBnPqA59YzloAncAYlMU/xGM2kwb8KAEwB zQyOK7PsWN002Ikb5qeBFOixg1s56Nphx08fuzhrEdDvwMQPIpnkfRRSSZGNfbf3gUB5 sR0gF590NTpuu2GFuA1rW1HFydb2lAvWKnHIKso4RS1C7VI/xOOCH32zAo9eR4PNuNi3 0XrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=R5TEIv7r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si5895580edx.371.2021.04.23.14.11.55; Fri, 23 Apr 2021 14:12:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=R5TEIv7r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232636AbhDWVJX (ORCPT + 99 others); Fri, 23 Apr 2021 17:09:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244204AbhDWVIn (ORCPT ); Fri, 23 Apr 2021 17:08:43 -0400 Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54072C06138E for ; Fri, 23 Apr 2021 14:08:05 -0700 (PDT) Received: by mail-oo1-xc29.google.com with SMTP id p12-20020a4a2f0c0000b02901ecdbb16887so4020687oop.5 for ; Fri, 23 Apr 2021 14:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=A22TFll9Blm6PfGJntS755LasWSXUim+ApdH7q9KXpA=; b=R5TEIv7r4kLuU5GuMWuxRcVR6NDvYx2skoH8US3RTsgU/Fbp/2PVhgI2qB1oIuefno 7jxT4w0OVfBtyKsNLQx3nU/NuBSntlMycnPfjjUb59ce/gDpthHN9M7whlXmWdynzzV4 mE5U3vaTyTDVk98Qw56lnGFYnGuEwSIbthXUM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=A22TFll9Blm6PfGJntS755LasWSXUim+ApdH7q9KXpA=; b=ChmBZGpbtBixN6eHQJ4uBvsUb6rzBURF457k6/lEN5MQSmLNhd7NcY/x3+zDd4e9tG ABAFo2TIAfY/9PWnQYRlnOOgxU2USnS5wO7mAtJwHcO3wFXYk67JnZbYuJiVKBC4ZvDn Ndq2e/Th826pkghGt0xHLAjX4C2WrgWUCBK+wMZiIXjC/tGaxaTMbN08Hahjzac0+MlA iyT+WsfccBLQXS76PTfUi2bTIeKZUteSBYHInQO4P40GlQLUFgYwBYzKd0fJePCrWnzE ETroQsBRaFF7j7VJJ58ICXQCWuQOfrfugsTa6fVmTCwtLBz7rjmUn3ErWS50XaPkoVCm POSw== X-Gm-Message-State: AOAM533Ry6GSpin6Qp7Jj/fo2zefNcjVf0zfhw5cXZmufc+5QQibCvZr U/UldqCcGHGS6gcXjd33RYgoug== X-Received: by 2002:a4a:2f09:: with SMTP id p9mr4337857oop.70.1619212084733; Fri, 23 Apr 2021 14:08:04 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id r19sm1482819oie.58.2021.04.23.14.08.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Apr 2021 14:08:04 -0700 (PDT) Subject: Re: [PATCH] drivers: pnp: proc.c: Removed unnecessary varibles To: Anupama K Patil , Jaroslav Kysela , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Adam , bkkarthik@pesu.pes.edu, gregkh@linuxfoundation.org, kernelnewbies@kernelnewbies.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan References: <20210422180322.7wlyg63kv3n2k6id@ubuntu> From: Shuah Khan Message-ID: Date: Fri, 23 Apr 2021 15:08:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210422180322.7wlyg63kv3n2k6id@ubuntu> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/22/21 12:03 PM, Anupama K Patil wrote: > de, e are two variables of the type 'struct proc_dir_entry' > which can be removed to save memory. This also fixes a coding style > issue reported by checkpatch where we are suggested to make assignment > outside the if statement. > Sounds like a reasonable change. > Signed-off-by: Anupama K Patil > --- > drivers/pnp/isapnp/proc.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c > index 785a796430fa..1ae458c02656 100644 > --- a/drivers/pnp/isapnp/proc.c > +++ b/drivers/pnp/isapnp/proc.c > @@ -57,21 +57,20 @@ static const struct proc_ops isapnp_proc_bus_proc_ops = { > static int isapnp_proc_attach_device(struct pnp_dev *dev) > { > struct pnp_card *bus = dev->card; > - struct proc_dir_entry *de, *e; > char name[16]; > > - if (!(de = bus->procdir)) { > + if (!bus->procdir) { > sprintf(name, "%02x", bus->number); It would make sense to change this to scnprintf() > - de = bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir); > - if (!de) > + bus->procdir = proc_mkdir(name, isapnp_proc_bus_dir); > + if (!bus->procdir) > return -ENOMEM; > } > sprintf(name, "%02x", dev->number); It would make sense to change this to scnprintf() > - e = dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, de, > + dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, bus->procdir, > &isapnp_proc_bus_proc_ops, dev); > - if (!e) > + if (!dev->procent) > return -ENOMEM; Shouldn't the procdir be deleted when proc_create_data() fails? > - proc_set_size(e, 256); > + proc_set_size(dev->procent, 256); > return 0; > } > > Note that isapnp_proc_init() doesn't check isapnp_proc_attach_device() return and handle errors and cleanup. thanks, -- Shuah