|
|
Log in / Subscribe / Register

The 5.7 kernel is out

The 5.7 kernel is out

Posted Jun 1, 2020 14:51 UTC (Mon) by adobriyan (guest, #30858)
In reply to: The 5.7 kernel is out by pharm
Parent article: The 5.7 kernel is out

clang-format does terrible things to carefully aligned C99 initializers and being buggy with "try =" (at least with current kernel settings).

> clang-format fs/proc/kcore.c


to post comments

The 5.7 kernel is out

Posted Jun 1, 2020 14:56 UTC (Mon) by mathstuf (subscriber, #69389) [Link]

Alignment is unfortunately one thing it doesn't understand. I've just used `// clang-format off` and `// clang-format on` comments to get it to not see those. But getting `clang-format` to settle formatting disputes saves a lot of time not fiddling around with whitespace arguments. Getting it to do the inverted Christmas tree declaration order would also save iterations for the subsystems that use it.

The 5.7 kernel is out

Posted Jun 1, 2020 15:29 UTC (Mon) by pharm (guest, #22305) [Link] (2 responses)

I bet it thinks try is part of a try .. catch statement. C formatting is not well separated from C++ formatting in clang-format.

The 5.7 kernel is out

Posted Jun 1, 2020 15:47 UTC (Mon) by pharm (guest, #22305) [Link] (1 responses)

Yup. Try switching the variable name from "try" to "try1". I’ve made a bug report: it really shouldn’t regard try as a keyword in C code.

The 5.7 kernel is out

Posted Jun 1, 2020 19:19 UTC (Mon) by pharm (guest, #22305) [Link]

That was quick! Looks like this will hopefully be fixed in the next release of clang-format: https://reviews.llvm.org/D80940

The 5.7 kernel is out

Posted Jun 1, 2020 19:51 UTC (Mon) by josh (subscriber, #17465) [Link]

> carefully aligned C99 initializers

In general, I'm in favor of never attempting to "align" anything other than the current indentation level.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds