linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* mtd/maps/ceiva.c: possibly uninitialised local variable nr
@ 2010-02-01 10:26 d binderman
  2010-02-09 11:47 ` Artem Bityutskiy
  2010-02-25 12:50 ` David Woodhouse
  0 siblings, 2 replies; 4+ messages in thread
From: d binderman @ 2010-02-01 10:26 UTC (permalink / raw)
  To: dwmw2; +Cc: linux-mtd



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/

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

end of thread, other threads:[~2010-02-25 13:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-01 10:26 mtd/maps/ceiva.c: possibly uninitialised local variable nr d binderman
2010-02-09 11:47 ` Artem Bityutskiy
2010-02-25 12:50 ` David Woodhouse
2010-02-25 13:25   ` Russell King

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).