[U-Boot] [PATCH 1/1] Make FAT code comply to coding rules.

Remy Bohmer linux at bohmer.net
Tue Dec 9 09:13:43 CET 2008


Hello Wolfgang,

> ...but your new code has new issues, too.

Nothing is perfect... Making this code perfect would require a
complete rewrite... ;-)
The (original) code is buggy too, because I have discovered a strange
bug which is causing me quite some headaches last week... ;-)
(I have a usb stick here which shows different contents in U-boot than
on Linux/Windows, U-boot shows the contents that was on the stick a
long time ago, and what it reads is even valid...)

At least formatting/whitespaces/tabs is better now.
Long indentations and similar code has been moved into separate
routines and so on.

> And this...
>> -     actsize=bytesperclust;
>> -     endclust=curclust;
>> -     do {
>> +     actsize = bytesperclust;
>> +     endclust = curclust;
>> +     for (;;) {
>>               /* search for consecutive clusters */
>> -             while(actsize < filesize) {
>> +             while (actsize < filesize) {
>>                       newclust = get_fatent(mydata, endclust);
>> -                     if((newclust -1)!=endclust)
>> -                             goto getit;
>> +                     if ((newclust - 1) != endclust) {
>> +                             if (get_cluster(mydata, curclust, buffer,
>> +                                                        (int)actsize) != 0) {
>> +                                     FAT_ERROR("Error reading cluster\n");
>> +                                     return -1;
>> +                             }
>> +                             gotsize += (int)actsize;
>> +                             filesize -= actsize;
>> +                             buffer += actsize;
>> +                             curclust = get_fatent(mydata, endclust);
>> +                             if (CHECK_CLUST(curclust, mydata->fatsize)) {
>> +                                     FAT_DPRINT("curclust: 0x%x\n",
>> +                                                curclust);
>> +                                     FAT_ERROR("Invalid FAT entry\n");
>> +                                     return gotsize;
>> +                             }
>> +                             actsize = bytesperclust;
>> +                             endclust = curclust;
>> +                             continue;
>> +                     }
>
> ...looks like a massive code change, not only a coding style cleanup.

No, I just reordered a strange construction, by moved a piece of code
that could only be reached by goto to a label to the place where the
goto was listed.
This made the code more readable. To me this is still just coding style.

> Please submit as two separate patches.

There are a few little things that could be put into a separate patch.
I will see what I can do...

Kind regards,

Remy


More information about the U-Boot mailing list