linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Josh Triplett <josh@joshtriplett.org>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christopher Li <sparse@chrisli.org>,
	Ingo Molnar <mingo@redhat.com>,
	Jeff Layton <jlayton@poochiereds.net>,
	Michal Marek <mmarek@suse.cz>, Neil Brown <neilb@suse.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-sparse@vger.kernel.org
Subject: Re: [PATCH 1/5] Add __designated_init, wrapping __attribute__((designated_init))
Date: Fri, 1 Aug 2014 13:45:29 -0700	[thread overview]
Message-ID: <20140801134529.40b46e92a48d9bf0c0abc139@linux-foundation.org> (raw)
In-Reply-To: <3130b0553b15518e3bef6d14c80280beed0f5ff9.1406850006.git.josh@joshtriplett.org>

On Thu, 31 Jul 2014 16:47:23 -0700 Josh Triplett <josh@joshtriplett.org> wrote:

> GCC 4.10 and newer, and Sparse, supports
> __attribute__((designated_init)), which marks a structure as requiring
> a designated initializer rather than a positional one.  This helps
> reduce churn and errors when used with _ops structures and similar
> structures designed for future extension.
> 
> Add a wrapper __designated_init, which turns into
> __attribute__((designated_init)) for Sparse or sufficiently new GCC.
> Enable the corresponding warning as an error.
> 
> The following semantic patch can help mark structures containing
> function pointers as requiring designated initializers:
> 
> @@
> identifier I, f;
> type T;
> @@
> 
> struct I {
> 	...
> 	T (*f)(...);
> 	...
> }
> + __designated_init

hm, dunno about this.

I think that the kernel should always use designated initializers
everywhere.  Perhaps there are a few special cases where positional
initializers provide a superior result but I'm not sure where those
might be.

In which case what we should do is to teach sparse to warn about
positional initializers then go fix them all up (lol).  After that
process is complete, this __designated_init tag would be just noise.

To support this perhaps a sparse tag would be needed which says
"positional initializers are OK here".  This way we're adding the
annotation to the exceptional cases, not to the common cases.



  parent reply	other threads:[~2014-08-01 20:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-31 23:47 [PATCH 1/5] Add __designated_init, wrapping __attribute__((designated_init)) Josh Triplett
2014-07-31 23:47 ` [PATCH 2/5] raid: Require designated initialization of structures Josh Triplett
2014-08-01  1:10   ` NeilBrown
2014-08-01  1:30     ` Josh Triplett
2014-07-31 23:47 ` [PATCH 3/5] fs: " Josh Triplett
2014-07-31 23:47 ` [PATCH 4/5] ftrace: " Josh Triplett
2014-07-31 23:48 ` [PATCH 5/5] include/linux/interrupt.h: " Josh Triplett
2014-08-01 20:45 ` Andrew Morton [this message]
2014-08-01 21:36   ` [PATCH 1/5] Add __designated_init, wrapping __attribute__((designated_init)) josh

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=20140801134529.40b46e92a48d9bf0c0abc139@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=bfields@fieldses.org \
    --cc=jlayton@poochiereds.net \
    --cc=josh@joshtriplett.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mmarek@suse.cz \
    --cc=neilb@suse.de \
    --cc=rostedt@goodmis.org \
    --cc=sparse@chrisli.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).