Linux supremo Linus Torvalds has made the use of indentation in kernel config files more ambiguous – intentionally, to weed out inferior parsers.
Kernel 6.9-rc4, the latest release candidate for the next version of the Linux kernel, came out yesterday. Among the usual drivers and bugfixes, it contains some more fixes for bcachefs, as well as some new mitigations against the recently-uncovered Native Branch History Injection attacks.
However, the change that brought the most amusement to the face of the Reg FOSS desk is a code change from Linus himself, titled Kconfig: add some hidden tabs on purpose. He switched some space-indented lines to tab-indented to catch out poor-quality parsers.
While Torvalds is famed for his robust approach to giving feedback, he has been working on it, and in 2018 he took a break to help him to get the emotions in his emails under better control.
This change could be one example of this. The kernel commandant spotted one particular code change, commit d96c36004e31 which had a single purpose:
Fix FTRACE_RECORD_RECURSION_SIZE entry, replace tab with a space character. It helps Kconfig parsers to read file without error.
Kconfig is the configuration language used to control the kernel build system, and like many other off-side rule languages, it uses indentation to delimit blocks. Yes, significant whitespace, just like in Python, YAML, and many other programming and configuration languages. Love it or hate it, you can't escape it.
In this change, he is intentionally making the use of indentation in kernel build configuration files more complicated, in order to force the authors of tools which parse such files to improve their game. As he explains:
Let's make sure it gets fixed. Because if you can't parse tabs as whitespace, you should not be parsing the kernel Kconfig files.
This seems to us to be an instance of Postel's Law, which he enshrined in RFC 761 in 1980: Be liberal in what you accept, and conservative in what you send. Many indentation-marked languages have a recommended style, such as Python's PEP-008, which says very clearly and distinctly:
Use 4 spaces per indentation level.
But in fact, although the specification is strict, the interpreter will happily accept different numbers of spaces, or tabs in some lines and spaces in others, so long as developers are consistent about how they use them. This is what Linus wants to see, and he quite rightly regards as broken whatever parsing tool it was that failed when it encountered tabs instead of spaces.
So, rather than a savagely critical email response, he is knowingly and with malice aforethought using more complicated indentation in order to expose tools that can't handle it. It should weed out the weaker tools, leaving only the fitter, better-adapted ones… while not publicly hurting anyone's feelings.
Think of it as evolution in action. ®
Source: The register