public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb
@ 2014-11-06 12:34 Wolfgang Denk
  2014-11-06 14:12 ` Heiko Schocher
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2014-11-06 12:34 UTC (permalink / raw)
  To: u-boot

Hello,

cppcheck reports:

[drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb

can you please have a look?  Thanks!

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If you're not part of the solution, then you're part of the  precipi-
tate.

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

* [U-Boot] [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb
  2014-11-06 12:34 [U-Boot] [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb Wolfgang Denk
@ 2014-11-06 14:12 ` Heiko Schocher
  2014-11-06 15:10   ` Wolfgang Denk
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2014-11-06 14:12 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang,

Am 06.11.2014 13:34, schrieb Wolfgang Denk:
> Hello,
>
> cppcheck reports:
>
> [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb
>
> can you please have a look?  Thanks!

I see in drivers/mtd/ubi/eba.c:

1267:                ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb)
1268:                        scan_eba[i][aeb->lnum] = aeb->pnum;
1269:
1270:                av = ubi_find_av(ai_fastmap, idx2vol_id(ubi, i));
1271:                if (!av)
1272:                       continue;
1273:
1274:                ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb)
1275:                        fm_eba[i][aeb->lnum] = aeb->pnum;

Why does cppcheck only report line 1275 not also line 1268 and also
1351? I could not currently see, why this pops up for line 1274 ...

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb
  2014-11-06 14:12 ` Heiko Schocher
@ 2014-11-06 15:10   ` Wolfgang Denk
  2014-11-07  4:52     ` Heiko Schocher
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2014-11-06 15:10 UTC (permalink / raw)
  To: u-boot

Dear Heiko,

In message <545B81D9.6070602@denx.de> you wrote:
> >
> > [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb
> >
> > can you please have a look?  Thanks!
> 
> I see in drivers/mtd/ubi/eba.c:
> 
> 1267:                ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb)
> 1268:                        scan_eba[i][aeb->lnum] = aeb->pnum;
> 1269:
> 1270:                av = ubi_find_av(ai_fastmap, idx2vol_id(ubi, i));
> 1271:                if (!av)
> 1272:                       continue;
> 1273:
> 1274:                ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb)
> 1275:                        fm_eba[i][aeb->lnum] = aeb->pnum;
> 
> Why does cppcheck only report line 1275 not also line 1268 and also
> 1351? I could not currently see, why this pops up for line 1274 ...

we should also look at the ubi_rb_for_each_entry() macro:

 912 #define ubi_rb_for_each_entry(rb, pos, root, member)                         \
 913         for (rb = rb_first(root),                                            \
 914              pos = (rb ? container_of(rb, typeof(*pos), member) : NULL);     \
 915              rb;                                                             \
 916              rb = rb_next(rb),                                               \
 917              pos = (rb ? container_of(rb, typeof(*pos), member) : NULL))

We can see there, that this will always set "pos", i. e. the 2nd
argument, to a well-defined value.

Looks like a false positive to me, then.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Where would we be without rhetorical questions?

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

* [U-Boot] [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb
  2014-11-06 15:10   ` Wolfgang Denk
@ 2014-11-07  4:52     ` Heiko Schocher
  0 siblings, 0 replies; 4+ messages in thread
From: Heiko Schocher @ 2014-11-07  4:52 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang,

Am 06.11.2014 16:10, schrieb Wolfgang Denk:
> Dear Heiko,
>
> In message<545B81D9.6070602@denx.de>  you wrote:
>>>
>>> [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb
>>>
>>> can you please have a look?  Thanks!
>>
>> I see in drivers/mtd/ubi/eba.c:
>>
>> 1267:                ubi_rb_for_each_entry(rb, aeb,&av->root, u.rb)
>> 1268:                        scan_eba[i][aeb->lnum] = aeb->pnum;
>> 1269:
>> 1270:                av = ubi_find_av(ai_fastmap, idx2vol_id(ubi, i));
>> 1271:                if (!av)
>> 1272:                       continue;
>> 1273:
>> 1274:                ubi_rb_for_each_entry(rb, aeb,&av->root, u.rb)
>> 1275:                        fm_eba[i][aeb->lnum] = aeb->pnum;
>>
>> Why does cppcheck only report line 1275 not also line 1268 and also
>> 1351? I could not currently see, why this pops up for line 1274 ...
>
> we should also look at the ubi_rb_for_each_entry() macro:
>
>   912 #define ubi_rb_for_each_entry(rb, pos, root, member)                         \
>   913         for (rb = rb_first(root),                                            \
>   914              pos = (rb ? container_of(rb, typeof(*pos), member) : NULL);     \
>   915              rb;                                                             \
>   916              rb = rb_next(rb),                                               \
>   917              pos = (rb ? container_of(rb, typeof(*pos), member) : NULL))
>
> We can see there, that this will always set "pos", i. e. the 2nd
> argument, to a well-defined value.
>
> Looks like a false positive to me, then.

Yes.

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

end of thread, other threads:[~2014-11-07  4:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 12:34 [U-Boot] [drivers/mtd/ubi/eba.c:1275]: (error) Uninitialized variable: aeb Wolfgang Denk
2014-11-06 14:12 ` Heiko Schocher
2014-11-06 15:10   ` Wolfgang Denk
2014-11-07  4:52     ` Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox