From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH] KNI: fix compilation warning 'missing-field-initializers' Date: Wed, 22 Oct 2014 12:00:46 +0200 Message-ID: <1818029.CqCeQSHIe6@xps13> References: <1ED644BD7E0A5F4091CF203DAFB8E4CC01D8288F@SHSMSX101.ccr.corp.intel.com> <4364683.dn9JoP4MXp@xps13> <54477DBD.1090701@bisdn.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev-VfR2kkLFssw@public.gmane.org To: Marc Sune Return-path: In-Reply-To: <54477DBD.1090701-kpkqNMk1I7M@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 2014-10-22 11:49, Marc Sune: > On 22/10/14 10:50, Thomas Monjalon wrote: > > 2014-10-22 10:42, Marc Sune: > >> The mutex needs to be initialized to RTE_SPINLOCK_INITIALIZER(0) too, or > >> move the initialization of the mutex to rte_kni_init(). > > RTE_SPINLOCK_INITIALIZER is { 0 } > > By initializing one field, all other fields are set to 0, so spinlock also. > > Just choose one field and it's OK. > > It should be tested with ICC also but I think it's OK. > > Seems that you are right, at least for C99: > > C99 Standard 6.7.8.21 > > If there are fewer initializers in a brace-enclosed list than > there are elements or members of an aggregate, or fewer characters > in a string literal used to initialize an array of known size than > there are elements in the array, the remainder of the aggregate > shall be initialized implicitly the same as objects that have static > storage duration. > > > I am not sure if there can be problems with other C dialects (e.g. C11), > I don't have the std here. So to prevent any problem with them (could > produce a dead-lock during first rte_kni_alloc() that could be difficult > to troubleshoot), I would still explicitly initialize the mutex, in one > or the other way. > > Just tell me if you agree and which one you prefer. No problem for initializing mutex. > I don't have an ICC license. I am always trying it with GCC and clang. That's why it's the Intel job to support ICC in DPDK :) -- Thomas