Pointing out that the Linux kernel uses
goto is like pointing at someone using a leg prosthesis, and shouting
Ha ha! Look at that stupid peg leg!
Me, I don't trust standards and regulations, not even ISO or POSIX C or MISRA-C or DO-178B. I highly appreciate the principles and the reasoning behind them, and try to abide by those –– especially security, robustness, reliability, and maintainability ––
depending on my needs, but practice trumps theory.
Always.Arguments like this one, especially when they get personal, make me go
.
Some of you argue based on DO-178B, the others do freestanding/hosted development under review-based quality control. They're not the same environment!
Define your own context, basis of argument and environment, before getting caught up in the argument. Yes, it leads to over-long posts like mine, but at least then you have a chance of arguing about the same thing, instead of a similar thing in wildly different contexts. Apples and pineapples.
One related case that I recently thought about is the fact that in ISO C, binary right shift of negative values is implementation defined. This means that a particular C compiler could choose to "optimize" code by having any right shift of a negative value do nothing. If anyone complains, they can simply point to the standard and point out – correctly – that they're fully compliant already.
Me,
I am only interested in compilers that generate an arithmetic right shift on negative two's complement integers, i.e.
(-29) >> 1 == -15. Generating anything else is just silly and anti-useful on the architectures I use, from 8-bit AVRs to 64-bit AMD64/x86-64 and ARM64.
Thus, my code is not strictly portable in the ISO C standard sense. Yet, in practice, my code tends to be quite portable, with just a set of notes and restrictions one can test.
This means that if anyone asks me if
>> on an
intN_t or
int_fastN_t-type expression is safe in C, my answer depends on the context (but I often assume one, rightly or wrongly, based on the names/labels the asker used). Or I explain the standard stance and my attitude towards it.
Similarly, I need to see a particular case of
goto use (including the project context), to even have an opinion about it.
To have an opinion about
goto use in the Linux kernel, without showing superior C constructs that yield the same or better machine code on all architectures, is just shouting "Ha-ha!". Not useful, not informative; just juvenile.