Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754108Ab1FNVYn (ORCPT ); Tue, 14 Jun 2011 17:24:43 -0400 Received: from mta11.charter.net ([216.33.127.80]:63016 "EHLO mta11.charter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753303Ab1FNVYj (ORCPT ); Tue, 14 Jun 2011 17:24:39 -0400 X-Authority-Analysis: v=1.1 cv=vT9vkN3vVXssH3Ov7r/wQUs/sfIFjNPEFFf4aeKIi4A= c=1 sm=1 a=p9YancsnzTcA:10 a=lE-93N_JSvIA:10 a=8nJEP1OIZ-IA:10 a=xzrYXqw+0zwiO4gHSXHcAg==:17 a=1TOdV14S6Zg42AI6UZ0A:9 a=5k-5Q243HpCcdUEdT9QA:7 a=wPNLvfGTeEIA:10 a=xzrYXqw+0zwiO4gHSXHcAg==:117 Message-ID: <4DF7D197.5070205@cuw.edu> Date: Tue, 14 Jun 2011 16:24:39 -0500 From: Greg Dietsche User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110505 Icedove/3.0.11 MIME-Version: 1.0 To: Julia Lawall CC: Gilles.Muller@lip6.fr, npalix.work@gmail.com, cocci@diku.dk, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] coccinelle: if (ret) return ret; return ret; semantic patch References: <1307989386-17666-1-git-send-email-Gregory.Dietsche@cuw.edu> <4DF67933.9080707@cuw.edu> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2394 Lines: 79 On 06/14/2011 12:50 AM, Julia Lawall wrote: > On Mon, 13 Jun 2011, Greg Dietsche wrote: > >> just curious... i see you usually just write "return ret;" here when posting. >> I've assumed that's because it will 1) work and 2) is close enough. >> >> You'll notice I've been doing: >> -return ret; >> +return ret; >> because it seems to help coccinelle realize that it can get rid of extra line >> feeds - does this make sense - or should i just be doing a "return ret"? >> > I wondered why you were doing that :) > > Is the problem that the removed if is being replaced by a blank line? If > so, that is not intentional. I will look into it. If it doesn't happen > always, an example where it does happen could be helpful. > > Some times it gets it right, so it's not always wrong. For example: diff -u -p a/arch/m68k/math-emu/fp_log.c b/arch/m68k/math-emu/fp_log.c --- a/arch/m68k/math-emu/fp_log.c 2011-06-13 14:06:37.943954469 -0500 +++ b/arch/m68k/math-emu/fp_log.c 2011-06-14 16:07:22.394954040 -0500 @@ -105,9 +105,6 @@ fp_fetoxm1(struct fp_ext *dest, struct f fp_monadic_check(dest, src); - if (IS_ZERO(dest)) - return dest; - return dest; } Here's an example where it got it "wrong" - notice how the blank line is missing the - : diff -u -p a/arch/frv/mm/pgalloc.c b/arch/frv/mm/pgalloc.c --- a/arch/frv/mm/pgalloc.c 2011-06-13 14:06:37.855954391 -0500 +++ b/arch/frv/mm/pgalloc.c 2011-06-14 16:07:16.714954008 -0500 @@ -136,8 +136,6 @@ pgd_t *pgd_alloc(struct mm_struct *mm) pgd_t *pgd; pgd = quicklist_alloc(0, GFP_KERNEL, pgd_ctor); - if (!pgd) - return pgd; return pgd; } but when I do -return ret; +return ret; then both of the above examples are "correct" Greg > The disadvantage of removing something and then adding it back is that > then Coccinelle takes over the pretty printing of that thing. Since ret > is usually a variable, it doesn't matter, and since Coccinelle tries to > follow Linux spacing conventions it might not matter either. But eg > f(a,b,c,d) would become f(a, b, c, d). > > julia > -- 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/