[U-Boot] [PATCH 4/7] JFFS2: Improve error checking

Detlev Zundel dzu at denx.de
Fri Apr 29 19:31:47 CEST 2011


Hi Baidu,

> Hi, Detlev
>
>
>>> @@ -1470,9 +1471,16 @@ jffs2_1pass_build_lists(struct part_info * part)
>>>       /* lcd_off(); */
>>>
>>>       /* if we are building a list we need to refresh the cache. */
>>> -     jffs_init_1pass_list(part);
>>> +     if(! jffs_init_1pass_list(part))
>>> +             return 0;
>>> +
>>
>> This is strange.  We now check for an error of jffs2_init_1pass_list,
>> which currently always returns 0, so let's see where you change that.
>> Ah, you don't (it's in line 671 in this file).  It's only in
>> jffs2_nand_1pass that you do a change, but even there we have a problem:
> Yes, we check the return value of function jffs_init_1pass_list().
> Also we add the check in nand flash.
> I do not konw what you are talking about.

The function 'jffs_init_1pass_list' is implemented in two files, i.e. in
fs/jffs2/jffs2_1pass.c and in fs/jffs2/jffs2_nand_1pass.c.  Your patch
inserts the actual malloc error checking only in the latter file,
whereas the check for return code is done in both files.  Just look at
your changes - how could your new test in jffs2_1pass ever fail as you
did not change the called function?

This is _plain inconsistent_ - you missed to do the same error checking
for the NOR flash case.

>>> diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c
>>> index 9bad690..885fa3c 100644
>>> --- a/fs/jffs2/jffs2_nand_1pass.c
>>> +++ b/fs/jffs2/jffs2_nand_1pass.c
>>> @@ -251,6 +251,7 @@ jffs_init_1pass_list(struct part_info *part)
>>>               pL->dir.listCompare = compare_dirents;
>>>               pL->frag.listCompare = compare_inodes;
>>>  #endif
>>> +             return 1;
>>
>> When malloc fails, we get no error output.
> You are too strict. Search the malloc in uboot. There are many places which
> do not even check the return value.

This is getting more and more ridiculous.  When writing new code, we
always have to conform to our own standards.  Now you insert an error
check but if it fails, you do not inform the user that he ran out of
memory but simply provide empty output?  So there is _no way_ of telling
a failed malloc from an empty directory?  And to argument for this
broken behavious you point to other places that do no error checking?

Sorry, you are loosing my interest of reviewing your code.

Best wishes
  Detlev

-- 
Peace of mind isn't at all superficial to technical work.  It's the
whole thing.   That which  produces it is good work  and that which
destroys it is bad work.
                                        -- Robert M. Pirsig
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de


More information about the U-Boot mailing list