lkml.org 
[lkml]   [2021]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v5] docs: Explain the desired position of function attributes
From
Date
On Tue, 2021-10-05 at 08:26 -0700, Kees Cook wrote:
> While discussing how to format the addition of various function
> attributes, some "unwritten rules" of ordering surfaced[1]. Capture as
> close as possible to Linus's preferences for future reference.
> +For example, using this function declaration example::
> +
> + __init void * __must_check action(enum magic value, size_t size, u8 count,
> + char *fmt, ...) __printf(4, 5) __malloc;

trivia: almost all fmt declarations should be const char *

> +Note that for a function **definition** (i.e. the actual function body),
> +the compiler does not allow function parameter attributes after the
> +function parameters. In these cases, they should go after the storage
> +class attributes (e.g. note the changed position of ``__printf(4, 5)``
> +below, compared to the **declaration** example above)::
> +
> + static __always_inline __init __printf(4, 5) void * __must_check action(enum magic value,
> + size_t size, u8 count, char *fmt, ...) __malloc

here too, and 80 columns?

> + {
> + ...
> + }

Or just put all the attributes before the storage class... <grumble/chuckle>

cheers, Joe

\
 
 \ /
  Last update: 2021-10-05 17:40    [W:0.064 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site