From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:37084 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756097AbaHAUpc (ORCPT ); Fri, 1 Aug 2014 16:45:32 -0400 Date: Fri, 1 Aug 2014 13:45:29 -0700 From: Andrew Morton Subject: Re: [PATCH 1/5] Add __designated_init, wrapping __attribute__((designated_init)) Message-Id: <20140801134529.40b46e92a48d9bf0c0abc139@linux-foundation.org> In-Reply-To: <3130b0553b15518e3bef6d14c80280beed0f5ff9.1406850006.git.josh@joshtriplett.org> References: <3130b0553b15518e3bef6d14c80280beed0f5ff9.1406850006.git.josh@joshtriplett.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kbuild-owner@vger.kernel.org List-ID: To: Josh Triplett Cc: "J. Bruce Fields" , Alexander Viro , Christopher Li , Ingo Molnar , Jeff Layton , Michal Marek , Neil Brown , Steven Rostedt , 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 On Thu, 31 Jul 2014 16:47:23 -0700 Josh Triplett 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.