Skip to contentSkip to conversation

Bad initialisers in pch_gbe_param.c:pch_gbe_check_options ?

DISCUSSION Dr. David Alan Gilbert 2 participants 2 messages Nov 21, 2010 – Nov 22, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

Signature · 4 lines
 -----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   |_______/
#1 lore raw

Hi Dave

Thank you for the pointing out.
This driver's author was changed to me from "Masayuki Ohtake".

So, I confirmed your pointing out and understood the issue. I will modified and submit the patch.

Best regards
Toshiharu Okada (OKI SEMICONDUCTOR)
-----
Date: Sun, 21 Nov 2010 17:17:10 +0000
From: "Dr. David Alan Gilbert" <[email protected]>

Quoted 5 lines

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

Quoted 8 lines

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,

Quoted 5 lines
   *******              .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)

Quoted 1 line

and r has two members, min and max. This initialiser is initialising the

whole

Quoted 14 lines

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 } }
};

Quoted 3 lines

(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

Quoted 13 lines

drivers/net/pch_gbe/pch_gbe_param.c:454:26: also defined here

Dave

Signature · 8 lines
 -----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   |_______/
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html