Re:Applying the Linus Torvalds “Good Taste” Coding Requirement
by MawKKe on Wednesday October 26, 2016 @09:32AM
(#12796280)
Comparing the two versions, I found the 'clever' version to have less cognitive overhead, since the reader has less state to keep track of (1 vs 2 variables).
I don't find the pointer syntax that difficult to reason with.
How would you expand the code?
Re:Applying the Linus Torvalds “Good Taste” Coding Requirement
by sverrirs on Wednesday October 26, 2016 @04:55AM
(#12794933)
Agree on the cognitive overhead.
People will and are arguing that "it is kernel code, it should be complicated" but I really think this is backwards. Because it is low level and debugging is really cognitively intense and difficult at this level the code should be even clearer and easier to understand.
Re:Applying the Linus Torvalds “Good Taste” Coding Requirement
by addicted on Wednesday October 26, 2016 @06:43AM
(#12795402)
People aren't arguing kernel code must be complicated. People are arguing that dealing with pointers should be second nature to kernel developers, so the lines of code causing you and me congnitive overhead should be second nature to a kernel Dev.
Re:Applying the Linus Torvalds “Good Taste” Coding Requirement
by TickleSteve on Wednesday October 26, 2016 @06:47AM
(#12795418)
I'm an embedded/real-time/bare-metal softie with over 20 years experience.... I do this stuff all day, every day.
This code is inherently too complex. it should be simplified
Further, I would consider Linus's one-liner 'indirect=...' to be 'clever' code.
If I were reviewing it, I would want it expanded into more obvious code as it requires too much cognitive overhead to parse.