netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bad initialisers in pch_gbe_param.c:pch_gbe_check_options ?
@ 2010-11-21 17:17 Dr. David Alan Gilbert
  2010-11-22  3:20 ` Toshiharu Okada
  0 siblings, 1 reply; 2+ messages in thread
From: Dr. David Alan Gilbert @ 2010-11-21 17:17 UTC (permalink / raw)
  To: masa-korg; +Cc: netdev, davem

Hi,
  The 'sparse' checker pointed me at the following code in pch_gbe_param.c
that does look wrong:

drivers/net/pch_gbe/pch_gbe_param.c:437:26: warning: Initializer entry defined twice
drivers/net/pch_gbe/pch_gbe_param.c:438:26:   also defined here

                static const struct pch_gbe_option opt = {
                        .type = range_option,
                        .name = "Transmit Descriptors",
                        .err  = "using default of "
                                __MODULE_STRING(PCH_GBE_DEFAULT_TXD),
                        .def  = PCH_GBE_DEFAULT_TXD,
   *******              .arg  = { .r = { .min = PCH_GBE_MIN_TXD } },
   *******              .arg  = { .r = { .max = PCH_GBE_MAX_TXD } }
                };

The structure has a union called arg inside of which are two structs (l and r)
and r has two members, min and max.  This initialiser is initialising the whole
of .arg twice; I wrote a little test stand alone program and indeed
when doing it this way 'min' ended up as zero.

I suggest what you really want is:
                static const struct pch_gbe_option opt = {
                        .type = range_option,
                        .name = "Transmit Descriptors",
                        .err  = "using default of "
                                __MODULE_STRING(PCH_GBE_DEFAULT_TXD),
                        .def  = PCH_GBE_DEFAULT_TXD,
                        .arg  = { .r = { .min = PCH_GBE_MIN_TXD,
                                         .max = PCH_GBE_MAX_TXD } }
                };

(There's also an equivalent pair a few lines below)

drivers/net/pch_gbe/pch_gbe_param.c:453:26: warning: Initializer entry defined twice
drivers/net/pch_gbe/pch_gbe_param.c:454:26:   also defined here

Dave
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\ gro.gilbert @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/

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

end of thread, other threads:[~2010-11-22  3:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-21 17:17 Bad initialisers in pch_gbe_param.c:pch_gbe_check_options ? Dr. David Alan Gilbert
2010-11-22  3:20 ` Toshiharu Okada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).