linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Johan Hovold <johan@kernel.org>, Michal Marek <mmarek@suse.com>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr
Subject: Re: [PATCH] coccinelle: misc: remove "complex return code" warnings
Date: Thu, 1 Oct 2015 13:47:18 -0400	[thread overview]
Message-ID: <20151001174718.GJ4284@localhost> (raw)
In-Reply-To: <alpine.DEB.2.02.1510010716280.2233@localhost6.localdomain6>

On Thu, Oct 01, 2015 at 07:20:10AM +0200, Julia Lawall wrote:
> On Wed, 30 Sep 2015, Johan Hovold wrote:
> 
> > This effectively reverts 932058a5d5f9 ("coccinelle: misc: semantic patch
> > to delete overly complex return code processing").
> > 
> > There can be both symmetry and readability reasons for not wanting to do
> > the final function call as part of the return statement and to maintain
> > a clear separation of success and error paths.
> > 
> > Since this is in no way mandated by the coding standard, let's just
> > remove this semantic patch to avoid having "clean up" patches being
> > posted over and over in response to these Coccinelle warnings.
> 
> What do you mean by "posted"?  Are you referring to 0-day build testing 
> or individual usage of make coccicheck?  Maybe it would make sense to 
> remove the semantic patch from 0-day build testing but leave it in the 
> kernel, perhaps removing the < 0 case because that one in practice doesn't 
> seem to turn up much that is useful?

Individuals running coccicheck on in-kernel code and posting patches to
"fix warnings", where the end result is not necessarily an improvement.

But I don't think these warnings should be enabled for 0-day build
testing either as it is should be up to the author to decide what style
to prefer in each case.

> Perhaps it could also be improved to detect a previous != 0 case and then 
> not return a warning.  On some functions, this change can make some nice 
> simplifications.

Yes, that would at least improve things.

I don't think warnings should be generated at all for the following
code:

{
	int ret;

	ret = init_a(...);
	if (ret)
		return ret;

	ret = init_b(...);
	if (ret)
		return ret;

	return 0;
}

as it is (at least to me) preferred over:

{
	int ret;

	ret = init_a(...);
	if (ret)
		return ret;

	return init_b(...);
}

for symmetry and readability reasons (e.g. I don't have to look at
init_b to figure out what the functions returns). And with a long
parameter list to init_b with line breaks, this would look even worse.

But either way, it should be up to the author of the code to decide what
style to use.

Thanks,
Johan

  reply	other threads:[~2015-10-01 17:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30 22:37 [PATCH] coccinelle: misc: remove "complex return code" warnings Johan Hovold
2015-10-01  5:20 ` Julia Lawall
2015-10-01 17:47   ` Johan Hovold [this message]
2015-10-02 21:33     ` Julia Lawall
2015-10-04 10:50       ` Johan Hovold
2015-10-03 16:24     ` Julia Lawall
2015-10-04 10:52       ` Johan Hovold
2015-10-03 16:25 ` Julia Lawall
2015-10-28  9:54   ` Johan Hovold
2015-10-28 10:04     ` Michal Marek
2015-10-28 10:09       ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151001174718.GJ4284@localhost \
    --to=johan@kernel.org \
    --cc=Gilles.Muller@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.com \
    --cc=nicolas.palix@imag.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).