From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752538AbbELFXf (ORCPT ); Tue, 12 May 2015 01:23:35 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:10789 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752354AbbELFXc (ORCPT ); Tue, 12 May 2015 01:23:32 -0400 X-IronPort-AV: E=Sophos;i="5.13,412,1427752800"; d="scan'208";a="142515375" Date: Tue, 12 May 2015 07:23:30 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@localhost6.localdomain6 To: Joe Perches cc: Michal Simek , linux-kernel@vger.kernel.org, Markus Elfring Subject: Re: [PATCH v2] net: ll_temac: Use one return statement instead of two In-Reply-To: <1431360053.2884.31.camel@perches.com> Message-ID: References: <3a0fa74dd703db5dac4816ef15b6a512ef0f2ec0.1431353091.git.michal.simek@xilinx.com> <1431355371.2884.11.camel@perches.com> <5550CA19.8090404@xilinx.com> <1431358794.2884.17.camel@perches.com> <5550CE4F.2070404@xilinx.com> <1431360053.2884.31.camel@perches.com> User-Agent: Alpine 2.02 (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 On Mon, 11 May 2015, Joe Perches wrote: > On Mon, 2015-05-11 at 17:48 +0200, Julia Lawall wrote: > > > > A coccinelle script might be rather more complicated > > > > than the simpler grep above, but perhaps the script > > > > could be a bit more complete as it could likely look > > > > at more code indentation styles. > > > > > > Julia: Any comment? > > > > Here is what I had in mind: > > > > if (...) { > > ... when != goto l; > > return C; > > } > > return C; > > > > C is a constant, to avoid that its value depends on the code in the ... > > Sure but I think that would miss several instances like: > > switch () { > ... > default: > return ; > } > return ; Switch Coccinelle is not very good at... > or the similar > > if (foo) { > if (qux) > return ; > } else { > return ; > } > > return ; It seems improbable, but I could look for that. Unfortunately, I don't see a way to deal with arbitrarily nested ifs. Basically, the control flow from one return doesn't go to the other. It goes from the return to the outside of the function. I guess something could be done by renaming all of the returns to function calls, but that tends to make a mess. It could be done to see if such cases are worth considering though. Another similar and popular construction is: if (...) { ... goto l; } l: julia