Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1431179AbdDYTd5 (ORCPT ); Tue, 25 Apr 2017 15:33:57 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:53595 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S946852AbdDYTdq (ORCPT ); Tue, 25 Apr 2017 15:33:46 -0400 X-IronPort-AV: E=Sophos;i="5.37,250,1488841200"; d="scan'208";a="221504294" Date: Tue, 25 Apr 2017 21:33:43 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Fabian Frederick cc: Gilles Muller , cocci@systeme.lip6.fr, Jan Kara , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1 linux-next] scripts/coccinelle/misc: Warn about NULL check on kmap() In-Reply-To: <20170425181116.2499-1-fabf@skynet.be> Message-ID: References: <20170425181116.2499-1-fabf@skynet.be> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1520 Lines: 71 On Tue, 25 Apr 2017, Fabian Frederick wrote: > This script removes NULL check on kmap() and all process involved > (OOM message ...) > > Thanks to Jan Kara for explanations. > > Signed-off-by: Fabian Frederick Acked-by: Julia Lawall > --- > scripts/coccinelle/misc/kmap.cocci | 43 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > create mode 100644 scripts/coccinelle/misc/kmap.cocci > > diff --git a/scripts/coccinelle/misc/kmap.cocci b/scripts/coccinelle/misc/kmap.cocci > new file mode 100644 > index 0000000..9ae4a6e > --- /dev/null > +++ b/scripts/coccinelle/misc/kmap.cocci > @@ -0,0 +1,43 @@ > +/// kmap never fails; remove NULL test case. > +/// > +// Copyright: (C) 2017 Fabian Frederick. GPLv2. > +// Comments: - > +// Options: --no-includes --include-headers > + > +virtual patch > +virtual org > +virtual report > +virtual context > + > +@r2 depends on patch@ > +expression E; > +position p; > +@@ > + > +E = kmap(...); > +- if (!E) { > +- ... > +- } > + > +@r depends on context || report || org @ > +expression E; > +position p; > +@@ > + > +* E = kmap(...); > +* if (@p!E) { > +* ... > +* } > + > +@script:python depends on org@ > +p << r.p; > +@@ > + > +cocci.print_main("kmap() can't fail, NULL check and special process is not needed", p) > + > +@script:python depends on report@ > +p << r.p; > +@@ > + > +msg = "WARNING: NULL check on kmap() result is not needed." > +coccilib.report.print_report(p[0], msg) > -- > 2.9.3 > >