From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rvdZC6Z3GzDqTn for ; Wed, 20 Jul 2016 23:49:39 +1000 (AEST) Date: Wed, 20 Jul 2016 15:38:11 +0200 (CEST) From: Julia Lawall To: SF Markus Elfring cc: linuxppc-dev@lists.ozlabs.org, Christophe Lombard , Ian Munsie , LKML , kernel-janitors@vger.kernel.org, Michael Ellerman Subject: Re: [PATCH] cxl: Delete an unnecessary check before the function call "of_node_put" In-Reply-To: <33fb6b04-9986-35ee-f4e2-0ebeb79c5e23@users.sourceforge.net> Message-ID: References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <33fb6b04-9986-35ee-f4e2-0ebeb79c5e23@users.sourceforge.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Wed, 20 Jul 2016, SF Markus Elfring wrote: > From: Markus Elfring > Date: Wed, 20 Jul 2016 15:10:32 +0200 > > The of_node_put() function tests whether its argument is NULL > and then returns immediately. > Thus the test around the call is not needed. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring > --- > drivers/misc/cxl/of.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/misc/cxl/of.c b/drivers/misc/cxl/of.c > index edc4583..333256a 100644 > --- a/drivers/misc/cxl/of.c > +++ b/drivers/misc/cxl/of.c > @@ -490,8 +490,7 @@ int cxl_of_probe(struct platform_device *pdev) > adapter->slices = 0; > } > > - if (afu_np) > - of_node_put(afu_np); > + of_node_put(afu_np); > return 0; > } I don't think that the call should be there at all. The loop only exits when afu_np is NULL. Furthermore, the loop should not be written as a for loop, but rather with for_each_child_of_node. julia