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] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 17 Dec 2009 18:33:12 -0500 (EST)
From:	Mikulas Patocka <mpatocka@...hat.com>
To:	Paul Mundt <lethal@...ux-sh.org>
cc:	linux-kernel@...r.kernel.org,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Alasdair G Kergon <agk@...hat.com>, dm-devel@...hat.com
Subject: Re: [PATCH] Drop 80-character limit in checkpatch.pl



On Fri, 18 Dec 2009, Paul Mundt wrote:

> On Thu, Dec 17, 2009 at 05:37:57PM -0500, Mikulas Patocka wrote:
> > On Thu, 17 Dec 2009, Paul Mundt wrote:
> > > On Tue, Dec 15, 2009 at 04:57:49PM -0500, Mikulas Patocka wrote:
> > > > (5) Wrapping makes long expressions harder to understand
> > > > --------------------------------------------------------
> > > > 
> > > > If I have a complex expression, I do not try to wrap it at predefined
> > > > 80-column boundaries, but at logical boundaries within the expression to make
> > > > it more readable (the brain can't find matching parentheses fast, so we can
> > > > help it by aligning the code according to topmost terms in the expression).
> > > > 
> > > > Example:
> > > > 				if (unlikely(call_some_function(s, value) != RET
> > > > _SUCCESS) ||
> > > > 				    (var_1 == prev_var_1 && var_2 == prev_var_2)
> > > >  ||
> > > > 				    flags & (FLAG_1 | FLAG_2) ||
> > > > 				    some_other_condition) {
> > > > 				}
> > > > 
> > > > Now, if we impose 80-column limit, we get this. One may argue that is looks
> > > > aesthetically better, but it is also less intelligible than the previous
> > > > version:
> > > > 				if (unlikely(call_some_function(s, value) !=
> > > > 				    RET_SUCCESS) || (var_1 == prev_var_1 &&
> > > > 				    var_2 == prev_var_2) || flags & (FLAG_1 |
> > > > 				    FLAG_2) || some_other_condition) {
> > > > 				}
> > > > 
> > > For starters, this is just crap. If you're writing code like this, then
> > > line wrapping is really the least of your concerns. Take your function
> > > return value and assign it to a variable before testing it in unlikely()
> > > as per existing conventions and most of this goes away in this example.
> > 
> > I wouldn't say that this is better:
> > 				int csf_failed, vars_equal, flags_12;
> > 
> > 				...
> > 
> > 				csf_failed = call_some_function(s, value) != RET_SUCCESS;
> > 				vars_equal = var_1 == prev_var_1 && var_2 == prev_var_2;
> > 				flags_12 = flags & (FLAG_1 | FLAG_2);
> > 				if (unlikely(csf_failed) || vars_equal ||
> > 				    flags_12 || some_other_conditions) {
> > 				}
> > 
> > If you think that it is better, it's OK, just write your code like that. 
> > And don't force it to everyone.
> > 
> No, I wouldn't say that that's better either, but that's also not how I
> suggested cleaning reworking it. We have existing conventions for how
> complex blocks are broken down in to more readable forms which you seem
> to have issues grasping. My point is that you are purposely obfuscating
> things, and therefore your entire rationale is suspect at best.

So, how would you clean this complex code block?

Mikulas
--
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