Linux Hardening
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Randy Dunlap <rdunlap@infradead.org>, Kees Cook <keescook@chromium.org>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-hardening@vger.kernel.org,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Subject: Re: [PATCH v5] docs: Explain the desired position of function attributes
Date: Tue, 05 Oct 2021 17:51:31 -0700	[thread overview]
Message-ID: <b59c7f33ff9c8443cf08204ec37383d734fbbf60.camel@perches.com> (raw)
In-Reply-To: <742567f3-f043-6fab-235a-5835ca025f54@infradead.org>

On Tue, 2021-10-05 at 12:15 -0700, Randy Dunlap wrote:
> On 10/5/21 10:04 AM, Kees Cook wrote:
> > On Tue, Oct 05, 2021 at 08:39:14AM -0700, Joe Perches wrote:
> > > 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 *
> > 
> > Heh, good point!
> > 
> > > > +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?
> > 
> > Kernel standard is now 100. *shrug*
> 
> That's more for exceptions, not the common rule.
> AFAIUI.

And for function definitions that are not static inline, when
separate function declarations exist, the function definition
does not need any attribute marking at all.



  reply	other threads:[~2021-10-06  0:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 15:26 [PATCH v5] docs: Explain the desired position of function attributes Kees Cook
2021-10-05 15:39 ` Joe Perches
2021-10-05 17:04   ` Kees Cook
2021-10-05 19:15     ` Randy Dunlap
2021-10-06  0:51       ` Joe Perches [this message]
2021-10-12 19:35 ` Jonathan Corbet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b59c7f33ff9c8443cf08204ec37383d734fbbf60.camel@perches.com \
    --to=joe@perches.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=keescook@chromium.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=rdunlap@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox