Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751665AbbFYLVd (ORCPT ); Thu, 25 Jun 2015 07:21:33 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:23665 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197AbbFYLVc (ORCPT ); Thu, 25 Jun 2015 07:21:32 -0400 Date: Thu, 25 Jun 2015 14:21:14 +0300 From: Dan Carpenter To: Maninder Singh Cc: abbotti@mev.co.uk, hsweeten@visionengravers.com, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, pankaj.m@samsung.com Subject: Re: [PATCH 1/1] staging/comedi: remove unnecessary check around pci_dev_put Message-ID: <20150625112114.GB28762@mwanda> References: <1435229426-39366-1-git-send-email-maninder1.s@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1435229426-39366-1-git-send-email-maninder1.s@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1162 Lines: 29 On Thu, Jun 25, 2015 at 04:20:26PM +0530, Maninder Singh wrote: > pci_dev_put cehcks for NULL pointer itself, > reported by coccinelle > This patch is correct but the motivation is wrong. The check in pci_dev_put() is like a sanity check. There are many functions which have a sanity check and many which do not, it is impossible for a human to remember the complete list of each. When we remove explicit checks for NULL and instead rely on the sanity checks it sometimes makes the code more subtle and difficult to read. In this case, "pcidev" can never be NULL so the check is misleading and makes the code more complicated. Removing it is a good thing. Also the attach function does not have a NULL check so when we remove this check we make the code more consistent. But in other cases, if "pcidev" could be NULL then we should keep the check so that the code is easier to read. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/