I think Linus is correct on this one.
I think Linus is correct on this one.
I'm ok with clever code when it's explained in words.
The idea here is to make the "p" pointer point on the "next" field of the current element instead of at the structure itself. There is the same amount of indirection in both solutions.
The first solution does pointer->structure->pointer, the "elegant" solution does pointer->pointer->structure. The reason the first one may be easier to read is because the C syntax "prefers" it, as it is a more common construct.
The latter approach is definitely not the easiest to understand. It is, however, what Linus considers «good taste in coding.»
That's neither here, nor there though.
The simplicity of a concept does not directly translate to how hard it makes the code (assembly is simpler in the sense of having fewer and simpler constructs than e.g. Python but much much harder to code in).
Conditionals, and the exponential increase in state space they bring, are still one of the biggest source of errors and complexity in code.