kfifo: initialize fifo accordingly to C99 standard
PATCH RESEND 1/1 kfifo: initialize fifo accordingly to C99 standard
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.
--- include/linux/kfifo.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
include/linux/kfifo.h +1 -4
@@ -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) {
Signature · 1 line
1.7.10.4
Quoted 4 lines · On Wed, 21 Nov 2012 16:31:11 +0200 Andy Shevchenko…
When build a kernel with "make W=1" we will get a warning about missing initializer. It comes from kfifo usage style. The
DEFINE_KFIFOmacro 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.
Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Wed, 21 Nov 2012 16:31:11 +0200 Andy Shevchenko…
When build a kernel with "make W=1" we will get a warning about missing initializer. It comes from kfifo usage style. The
DEFINE_KFIFOmacro 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.osamples/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
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 16 lines · Andy Shevchenko
Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Wed, 21 Nov 2012 16:31:11 +0200 Andy Shevchenko…
When build a kernel with "make W=1" we will get a warning about missing initializer. It comes from kfifo usage style. The
DEFINE_KFIFOmacro 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;
Quoted 7 lines
CC [M]
samples/kfifo/inttype-example.osamples/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.osamples/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]
Quoted 1 line
gcc (Debian 4.7.2-2) 4.7.2
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 4 lines · On Wed, 21 Nov 2012 16:31:11 +0200 Andy Shevchenko…
When build a kernel with "make W=1" we will get a warning about missing initializer. It comes from kfifo usage style. The
DEFINE_KFIFOmacro 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.
Quoted 8 lines · Andrew Morton
Quoted 4 lines · On Wed, 21 Nov 2012 16:31:11 +0200 Andy Shevchenko…
When build a kernel with "make W=1" we will get a warning about missing initializer. It comes from kfifo usage style. The
DEFINE_KFIFOmacro doesn't initialize the buf[] field of the fifo structure. So, using C99 style helps in such case.
Quoted 7 lines
This doesn't actually work:
drivers/pci/pcie/aer/aerdrv_core.c:573: error: unknown field 'kfifo' specified in initializerdrivers/pci/pcie/aer/aerdrv_core.c:573: error: unknown field 'in' specified in initializerdrivers/pci/pcie/aer/aerdrv_core.c:573: warning: missing braces around initializerdrivers/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
Quoted 1 line
gcc-4.4.4.
gcc 4.7.2 might be the case.
Signature · 2 lines
With Best Regards, Andy Shevchenko