lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 12 May 2015 07:23:30 +0200 (CEST)
From:	Julia Lawall <julia.lawall@...6.fr>
To:	Joe Perches <joe@...ches.com>
cc:	Michal Simek <michal.simek@...inx.com>,
	linux-kernel@...r.kernel.org,
	Markus Elfring <elfring@...rs.sourceforge.net>
Subject: Re: [PATCH v2] net: ll_temac: Use one return statement instead of
 two



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 (<foo>) {
> 		...
> 	default:
> 		return <bar>;
> 	}
> 	return <bar>;

Switch Coccinelle is not very good at...

> or the similar
> 
> 	if (foo) {
> 		if (qux)
> 			return <bar>;
> 	} else {
> 		return <baz>;
> 	}
> 
> 	return <baz>;

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ