Re: function prototype element ordering

From: Linus Torvalds
Date: Wed Sep 22 2021 - 17:16:06 EST


On Wed, Sep 22, 2021 at 12:24 AM Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
>
> Attributes should be on their own line, they can be quite lengthy.

No, no no. They really shouldn't.

First off, no normal code should use that "__attribute__(())" syntax
anyway. It's ugly and big, and many of the attributes are
compiler-specific anyway.

So the "quite lengthy" argument is bogus, because the actual names you
should use are things like "__packed" or "__pure" or "__user" etc.

But the "on their own line" is complete garbage to begin with. That
will NEVER be a kernel rule. We should never have a rule that assumes
things are so long that they need to be on multiple lines.

We don't put function return types on their own lines either, even if
some other projects have that rule (just to get function names at the
beginning of lines or some other odd reason).

So no, attributes do not go on their own lines, and they also
generally don't go before the thing they describe. Your examples are
wrong, and explicitly against kernel rules.

Linus