From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F485C43381 for ; Fri, 15 Feb 2019 13:02:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3ACC21A80 for ; Fri, 15 Feb 2019 13:02:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394813AbfBONCJ (ORCPT ); Fri, 15 Feb 2019 08:02:09 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:48022 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726864AbfBONCJ (ORCPT ); Fri, 15 Feb 2019 08:02:09 -0500 X-IronPort-AV: E=Sophos;i="5.58,372,1544482800"; d="scan'208";a="296307215" Received: from vaio-julia.rsr.lip6.fr ([132.227.76.33]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2019 14:02:06 +0100 Date: Fri, 15 Feb 2019 14:02:05 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Markus Elfring cc: Wen Yang , Gilles Muller , Nicolas Palix , Michal Marek , Yi Wang , Masahiro Yamada , Wen Yang , Cheng Shengyu , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH v5] Coccinelle: semantic code search for missing put_device() In-Reply-To: <94e4b3e6-87a4-aea2-dfef-44d308f0fb4f@web.de> Message-ID: References: <1550217319-40418-1-git-send-email-wen.yang99@zte.com.cn> <94e4b3e6-87a4-aea2-dfef-44d308f0fb4f@web.de> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-662799820-1550235726=:3617" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --8323329-662799820-1550235726=:3617 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Fri, 15 Feb 2019, Markus Elfring wrote: > > +@search exists@ > > +local idexpression id; > > +expression x,e,e1; > > +position p1,p2; > > +type T,T1,T2,T3; > > +@@ > > + > > +id = of_find_device_by_node@p1(x) > > +... when != e = id > > +if (id == NULL || ...) { ... return ...; } > > +... when != put_device(&id->dev) > … > > + when != if (id) { ... put_device(&id->dev) ... } > … > > I would interpret this SmPL code in the way that the if statement > for the pointer check is “optional” in this line. > Is it an extra and redundant SmPL specification when the reference > release function could eventually be found just anywhere within > an implementation? The proposed when code is correct. It is not redundant, because it checks for a particular control-flow pattern. julia > > > Will a need evolve to develop a similar source code search approach > for safer resource management with other function combinations? > > Regards, > Markus > --8323329-662799820-1550235726=:3617--