From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752020AbcAEOSN (ORCPT ); Tue, 5 Jan 2016 09:18:13 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:17337 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751870AbcAEOSJ (ORCPT ); Tue, 5 Jan 2016 09:18:09 -0500 X-IronPort-AV: E=Sophos;i="5.20,525,1444687200"; d="scan'208";a="195701373" Date: Tue, 5 Jan 2016 15:17:57 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Andrzej Hajda cc: Julia Lawall , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Gilles Muller , Nicolas Palix , Michal Marek , open list , "moderated list:COCCINELLE/Semantic Patches (SmPL)" Subject: Re: [PATCH v6] coccinelle: tests: unsigned value cannot be lesser than zero In-Reply-To: <1451893531-15817-1-git-send-email-a.hajda@samsung.com> Message-ID: References: <1451893531-15817-1-git-send-email-a.hajda@samsung.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) 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 > +@script:python depends on org@ > +p << r_cmp.p; > +e << r.e = ""; > +@@ > + > +msg = "WARNING: Unsigned expression compared with zero: %s" % (e) > +coccilib.org.print_todo(p[0], msg) > + > +@script:python depends on report@ > +p << r_cmp.p; > +e << r.e = ""; > +@@ > + > +msg = "WARNING: Unsigned expression compared with zero: %s" % (e) > +if e: > + coccilib.report.print_report(p[0], msg) Is it intentional that these don't do the same thing? The report case has an if on e, while the org case does not. If you don't want a report when e doesn't have a value, you could just remove the = "" from the declaration of e. That is to give a default value of e, to allow the rule to be executed when e doesn't have a value. julia From mboxrd@z Thu Jan 1 00:00:00 1970 From: julia.lawall@lip6.fr (Julia Lawall) Date: Tue, 5 Jan 2016 15:17:57 +0100 (CET) Subject: [Cocci] [PATCH v6] coccinelle: tests: unsigned value cannot be lesser than zero In-Reply-To: <1451893531-15817-1-git-send-email-a.hajda@samsung.com> References: <1451893531-15817-1-git-send-email-a.hajda@samsung.com> Message-ID: To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr > + at script:python depends on org@ > +p << r_cmp.p; > +e << r.e = ""; > +@@ > + > +msg = "WARNING: Unsigned expression compared with zero: %s" % (e) > +coccilib.org.print_todo(p[0], msg) > + > + at script:python depends on report@ > +p << r_cmp.p; > +e << r.e = ""; > +@@ > + > +msg = "WARNING: Unsigned expression compared with zero: %s" % (e) > +if e: > + coccilib.report.print_report(p[0], msg) Is it intentional that these don't do the same thing? The report case has an if on e, while the org case does not. If you don't want a report when e doesn't have a value, you could just remove the = "" from the declaration of e. That is to give a default value of e, to allow the rule to be executed when e doesn't have a value. julia