[lkml]   [2009]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] New attribute designated_init: mark a struct as requiring designated init
On Sat, Oct 10, 2009 at 1:58 AM, Josh Triplett <> wrote:
> Some structure types provide a set of fields of which most users will
> only initialize the subset they care about.  Users of these types should
> always use designated initializers, to avoid relying on the specific
> structure layout.  Examples of this type of structure include the many

The patch is very well written with nice documentations and test case.
It applies and runs fine.

I am curious weather this is some thing the kernel developers want to
use. Please speak up if you want to annotate the kernel structure to
issue such warning. If some one use it, I have no problem adding it to

I am not sure how useful this is yet. If the structure is changed, most
likely the positional initialization will fail due to type mismatching.
Some real life example how this feature can expose some otherwise
hard to detect bug would be nice.

With this approach, we need to annotate the kernel to benefit from it.
Another idea is that we can find out how different part of the kernel
initialize the same structure. If most of them using designated init then
the few non-conforming can get a warning. This approach is more
complicate. But it does not need to change the kernel.

> +                               warning(e->pos, "%s%s%spositional init of field in %s %s, declared with attribute designated_init",
> +                                       ctype->ident ? "in initializer for " : "",
> +                                       ctype->ident ? ctype->ident->name : "",

ident->name has no guarantee of terminating by NUL.
You want to use "%.*s" with ident->size, ident->name here.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2009-10-10 12:39    [W:0.052 / U:0.148 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site