Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp290609imm; Thu, 20 Sep 2018 23:47:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbxHcnTZs8ZObNvm+wEoIBu+kZ4VaKCk8ElSCM6w05/xjSIXkRiZVtRJbKYEIG8Et+aohhK X-Received: by 2002:a63:4107:: with SMTP id o7-v6mr9090590pga.256.1537512429823; Thu, 20 Sep 2018 23:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537512429; cv=none; d=google.com; s=arc-20160816; b=PiPaqpDSNaCh4y6JDkoSAQ5Zf25LvUMkGmtXsgQDcvor2FDVhbu9oifLyO3/ZRJYue H/gpj1vhkEv3LMGf3gnQ2ro2tDGo/+R7A7eNdIxlFQje9e6Pmmt9tck2j2ZKvgNDnjED /7t8mqch544ye5K8uLLGziAo7k1tawzwOVfgsRhCsvvzY78h5tqhiLq7NS/FQtkSyoJW PlAVSEBeNDdS052eaUk4S50RAjosPFQ5vi1pjTbM91aH7xjC7eEt0Q0L5350o/HPNICX SQmuxRI6X0kUbnEuTRs4EzBEBEr1bweqZwkkwasJO0wvGNal+0mgQ/98oaK+hZcfbJMp IoEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=UWMj8iVL0JUAH0nl3sH7Tqgm0fn1HsTxbB3Bm13SQp8=; b=nJ+qVwVwD2qIrow9YzhbfeuMOr0XdWrlSqCAUcmVeCCOuJNuwTqLTKQl44fxfw3Uxt TuOtm7qKHWIgDYmFZQl5+KbzyrOkBgiLm7tzMQodWyHX0oFWQpQm8oGJw/+gbgyl1Sll Px9tdBTPMDDO21f0lytVu5Ja7dXDXY6dfvZNrYQNEY3S9igjYGFDGfx0+rxhSuqF4+a3 eEwp6MgXAc7tihcjysvJO4sN1jsGBukd0wYF6IXsHqxpqt5iRNRSEmueJmwrdtpDa31X 3eS3lneRcU+9njZc73dkd539QNVgfTw3Hds6UBPR0QNGMnBFCSIUV7+Bk3Qx4pdfivOk sJtg== 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 u91-v6si27021797plb.73.2018.09.20.23.46.53; Thu, 20 Sep 2018 23:47:09 -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 S2389340AbeIUMd6 (ORCPT + 99 others); Fri, 21 Sep 2018 08:33:58 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:65168 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbeIUMd6 (ORCPT ); Fri, 21 Sep 2018 08:33:58 -0400 X-IronPort-AV: E=Sophos;i="5.54,283,1534834800"; d="scan'208";a="19945779" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES128-SHA; 20 Sep 2018 23:46:31 -0700 Received: from ajaysk-VirtualBox (10.10.76.4) by CHN-SV-EXCH01.mchp-main.com (10.10.76.37) with Microsoft SMTP Server id 14.3.352.0; Thu, 20 Sep 2018 23:46:29 -0700 Date: Fri, 21 Sep 2018 12:01:16 +0530 From: Ajay Singh To: Nathan Chancellor CC: , Aditya Shankar , Ganesh Krishna , Greg Kroah-Hartman , , , Subject: Re: [PATCH] staging: wilc1000: Remove unnecessary pointer check Message-ID: <20180921120116.603b1de6@ajaysk-VirtualBox> In-Reply-To: <20180921053911.GA5170@flashbox> References: <20180920212648.25181-1-natechancellor@gmail.com> <32473.1537507532@turing-police.cc.vt.edu> <20180921053911.GA5170@flashbox> Organization: Microchip Technology X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reviewed-by: Ajay Singh On Thu, 20 Sep 2018 22:39:11 -0700 Nathan Chancellor wrote: > On Fri, Sep 21, 2018 at 01:25:32AM -0400, valdis.kletnieks@vt.edu > wrote: > > On Thu, 20 Sep 2018 14:26:49 -0700, Nathan Chancellor said: > > > Clang warns that the address of a pointer will always evaluated > > > as true in a boolean context: > > > > > > drivers/staging/wilc1000/linux_wlan.c:267:20: warning: address of > > > 'vif->ndev->dev' will always evaluate to 'true' > > > [-Wpointer-bool-conversion] > > > if (!(&vif->ndev->dev)) > > > ~ ~~~~~~~~~~~^~~ > > > 1 warning generated. > > > > > > Since this statement always evaluates to false due to the logical > > > not, remove it. > > > > Often, "just nuke it because it's now dead code" isn't the best > > answer... > > > > At one time, that was likely intended to be checking whether ->dev > > was a null pointer, to make sure we don't pass request_firmware() a > > null pointer and oops the kernel, or other things that go > > pear-shaped.... > > > > So the question becomes: Is it safe to just remove it, or was it > > intended to test for something that could legitimately be null if > > we've hit an error along the way (which means we should fix the > > condition to be proper and acceptable to both gcc and clang)? > > > > > > I certainly considered whether or not removing the check versus fixing > it was the correct answer. Given that this check can be traced back to > the initial check in of the driver in 2015, I figured it was safe to > remove it (since a null pointer dereference would most likely have > been noticed by now). > > Most patches addressing this warning just remove the check given that > it's not actually changing the code, such as commit a7dc662c6a7b > ("ASoC: codecs: PCM1789: unconditionally flush work"). However, if > the driver authors and/or maintainers think that this check should be > something else (maybe checking that the contents of dev is not null > versus the address, I'm perfectly happy to submit a v2 with this > change. > The 'if' condition was intended to check the validity of net_device structure, but i think its not required here. The device pointer used in request_firmware(), was received in the probe functions and different from the one checked in 'if' condition. Thus its safe to remove the 'if (!(&vif->ndev->dev))' condition block. Regards, Ajay