mtd/maps/ceiva.c: possibly uninitialised local variable nr

d binderman dcb314 at hotmail.com
Mon Feb 1 05:26:26 EST 2010



Hello there,

I just ran the sourceforge tool cppcheck over the source code of the
new Linux kernel 2.6.33-rc6

It said

[./mtd/maps/ceiva.c:269]: (error) Uninitialized variable: nr

The source code is

static int __init clps_setup_flash(void)
{
        int nr;

#ifdef CONFIG_ARCH_CEIVA
        if (machine_is_ceiva()) {
                info[0].base = CS0_PHYS_BASE;
                info[0].size = SZ_32M;
                info[0].width = CEIVA_FLASH_WIDTH;
                info[1].base = CS1_PHYS_BASE;
                info[1].size = SZ_32M;
                info[1].width = CEIVA_FLASH_WIDTH;
                nr = 2;
        }
#endif
        return nr;
}

There is no code to cope with the case that function machine_is_ceiva() returns 0
or that CONFIG_ARCH_CEIVA is undefined.

Suggest new belt'n'braces code

static int __init clps_setup_flash(void)
{
        int nr = 0;

#ifdef CONFIG_ARCH_CEIVA
        if (machine_is_ceiva()) {
                info[0].base = CS0_PHYS_BASE;
                info[0].size = SZ_32M;
                info[0].width = CEIVA_FLASH_WIDTH;
                info[1].base = CS1_PHYS_BASE;
                info[1].size = SZ_32M;
                info[1].width = CEIVA_FLASH_WIDTH;
                nr = 2;
        }
#endif
        return nr;
}

Regards

David Binderman

 		 	   		  
_________________________________________________________________
Tell us your greatest, weirdest and funniest Hotmail stories
http://clk.atdmt.com/UKM/go/195013117/direct/01/


More information about the linux-mtd mailing list