lkml.org 
[lkml]   [2014]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/5] Add __designated_init, wrapping __attribute__((designated_init))
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.




\
 
 \ /
  Last update: 2014-08-01 23:21    [W:0.049 / U:5.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site