All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard
@ 2012-11-21 14:31 Andy Shevchenko
  2012-11-28 23:56 ` Andrew Morton
  2012-11-29  1:51 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2012-11-21 14:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, Stefani Seibold, Greg Kroah-Hartman

When build a kernel with "make W=1" we will get a warning about missing
initializer. It comes from kfifo usage style. The DEFINE_KFIFO macro doesn't
initialize the buf[] field of the fifo structure. So, using C99 style helps in
such case.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Stefani Seibold <stefani@seibold.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/kfifo.h |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 10308c6..3de51a1 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -155,8 +155,7 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
 #define DEFINE_KFIFO(fifo, type, size) \
 	DECLARE_KFIFO(fifo, type, size) = \
 	(typeof(fifo)) { \
-		{ \
-			{ \
+		.kfifo = { \
 			.in	= 0, \
 			.out	= 0, \
 			.mask	= __is_kfifo_ptr(&(fifo)) ? \
@@ -166,11 +165,9 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
 			.data	= __is_kfifo_ptr(&(fifo)) ? \
 				NULL : \
 				(fifo).buf, \
-			} \
 		} \
 	}
 
-
 static inline unsigned int __must_check
 __kfifo_uint_must_check_helper(unsigned int val)
 {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard
  2012-11-21 14:31 [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard Andy Shevchenko
@ 2012-11-28 23:56 ` Andrew Morton
  2012-11-29  9:21   ` Andy Shevchenko
  2012-11-29  1:51 ` Andrew Morton
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2012-11-28 23:56 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Stefani Seibold, Greg Kroah-Hartman

On Wed, 21 Nov 2012 16:31:11 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> When build a kernel with "make W=1" we will get a warning about missing
> initializer. It comes from kfifo usage style. The DEFINE_KFIFO macro doesn't
> initialize the buf[] field of the fifo structure. So, using C99 style helps in
> such case.

I see no such warning.  When fixing warnings or compilation errors,
please always quote the compiler output in the changelog.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard
  2012-11-21 14:31 [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard Andy Shevchenko
  2012-11-28 23:56 ` Andrew Morton
@ 2012-11-29  1:51 ` Andrew Morton
  2012-11-29 13:05   ` Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2012-11-29  1:51 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Stefani Seibold, Greg Kroah-Hartman

On Wed, 21 Nov 2012 16:31:11 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> When build a kernel with "make W=1" we will get a warning about missing
> initializer. It comes from kfifo usage style. The DEFINE_KFIFO macro doesn't
> initialize the buf[] field of the fifo structure. So, using C99 style helps in
> such case.

This doesn't actually work:

drivers/pci/pcie/aer/aerdrv_core.c:573: error: unknown field 'kfifo' specified in initializer
drivers/pci/pcie/aer/aerdrv_core.c:573: error: unknown field 'in' specified in initializer
drivers/pci/pcie/aer/aerdrv_core.c:573: warning: missing braces around initializer
drivers/pci/pcie/aer/aerdrv_core.c:573: warning: (near initialization for '(anonymous).<anonymous>.kfifo')
drivers/pci/pcie/aer/aerdrv_core.c:573: error: unknown field 'out' specified in initializer

gcc-4.4.4.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard
  2012-11-28 23:56 ` Andrew Morton
@ 2012-11-29  9:21   ` Andy Shevchenko
  2012-11-29 12:57     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2012-11-29  9:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andy Shevchenko, linux-kernel, Stefani Seibold, Greg Kroah-Hartman

On Thu, Nov 29, 2012 at 1:56 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Wed, 21 Nov 2012 16:31:11 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
>> When build a kernel with "make W=1" we will get a warning about missing
>> initializer. It comes from kfifo usage style. The DEFINE_KFIFO macro doesn't
>> initialize the buf[] field of the fifo structure. So, using C99 style helps in
>> such case.
>
> I see no such warning.  When fixing warnings or compilation errors,
> please always quote the compiler output in the changelog.

Oh, I did wrong assumption. However, it looks like linux-stable 3.0.y
is affected;

  CC [M]  samples/kfifo/inttype-example.o
samples/kfifo/inttype-example.c:44:506: warning: missing initializer
[-Wmissing-field-initializers]
samples/kfifo/inttype-example.c:44:506: warning: (near initialization
for ‘(anonymous).buf’) [-Wmissing-field-initializers]

And it seems that my solution not the one which is used in linux-next.

gcc (Debian 4.7.2-2) 4.7.2


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard
  2012-11-29  9:21   ` Andy Shevchenko
@ 2012-11-29 12:57     ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2012-11-29 12:57 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andy Shevchenko, linux-kernel, Stefani Seibold, Greg Kroah-Hartman

On Thu, Nov 29, 2012 at 11:21 AM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Thu, Nov 29, 2012 at 1:56 AM, Andrew Morton
> <akpm@linux-foundation.org> wrote:
>> On Wed, 21 Nov 2012 16:31:11 +0200
>> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>>
>>> When build a kernel with "make W=1" we will get a warning about missing
>>> initializer. It comes from kfifo usage style. The DEFINE_KFIFO macro doesn't
>>> initialize the buf[] field of the fifo structure. So, using C99 style helps in
>>> such case.
>>
>> I see no such warning.  When fixing warnings or compilation errors,
>> please always quote the compiler output in the changelog.
>
> Oh, I did wrong assumption. However, it looks like linux-stable 3.0.y
> is affected;
>
>   CC [M]  samples/kfifo/inttype-example.o
> samples/kfifo/inttype-example.c:44:506: warning: missing initializer
> [-Wmissing-field-initializers]
> samples/kfifo/inttype-example.c:44:506: warning: (near initialization
> for ‘(anonymous).buf’) [-Wmissing-field-initializers]
>
> And it seems that my solution not the one which is used in linux-next.

Okay. I found the commit f858ee8b8cd8c216ddbeefae6e047ce90cae9cca
("kbuild: disable -Wmissing-field-initializers for W=1") hides the
warning.
After reverting this one I get the same warning as before:

  CC [M]  samples/kfifo/inttype-example.o
samples/kfifo/inttype-example.c:44:506: warning: missing initializer
[-Wmissing-field-initializers]
samples/kfifo/inttype-example.c:44:506: warning: (near initialization
for ‘(anonymous).buf’) [-Wmissing-field-initializers]

> gcc (Debian 4.7.2-2) 4.7.2


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard
  2012-11-29  1:51 ` Andrew Morton
@ 2012-11-29 13:05   ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2012-11-29 13:05 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andy Shevchenko, linux-kernel, Stefani Seibold, Greg Kroah-Hartman

On Thu, Nov 29, 2012 at 3:51 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Wed, 21 Nov 2012 16:31:11 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
>> When build a kernel with "make W=1" we will get a warning about missing
>> initializer. It comes from kfifo usage style. The DEFINE_KFIFO macro doesn't
>> initialize the buf[] field of the fifo structure. So, using C99 style helps in
>> such case.
>
> This doesn't actually work:
>
> drivers/pci/pcie/aer/aerdrv_core.c:573: error: unknown field 'kfifo' specified in initializer
> drivers/pci/pcie/aer/aerdrv_core.c:573: error: unknown field 'in' specified in initializer
> drivers/pci/pcie/aer/aerdrv_core.c:573: warning: missing braces around initializer
> drivers/pci/pcie/aer/aerdrv_core.c:573: warning: (near initialization for '(anonymous).<anonymous>.kfifo')
> drivers/pci/pcie/aer/aerdrv_core.c:573: error: unknown field 'out' specified in initializer

It's strange. After I reverted the mentioned commit (about
Makefile.build) and applied my patch I got no warnings
  CC [M]  samples/kfifo/inttype-example.o
  CC [M]  samples/kfifo/record-example.o

> gcc-4.4.4.

gcc 4.7.2 might be the case.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-29 13:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-21 14:31 [PATCH, resend] kfifo: initialize fifo accordingly to C99 standard Andy Shevchenko
2012-11-28 23:56 ` Andrew Morton
2012-11-29  9:21   ` Andy Shevchenko
2012-11-29 12:57     ` Andy Shevchenko
2012-11-29  1:51 ` Andrew Morton
2012-11-29 13:05   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.