[U-Boot-Users] [PATCH 3/4] Move buffer print code from md commandto common function

Ulf Samuelsson ulf at atmel.com
Wed Feb 14 20:52:49 CET 2007


Looks like your code boils down to:

if ((rc = read_dataflash(addr, (linebytes/size)*size, linebuf)) == DATAFLASH_OK){
             print_buffer(addr, linebuf, size, linebytes/size,
              DISP_LINE_LEN/size);
} else { /* addr does not correspond to DataFlash */
            print_buffer(addr, (void*)addr, size, linebytes/size,
             DISP_LINE_LEN/size);
}

Would it not generate less (better) code if you do something like:

rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
p = (rc == DATAFLASH_OK)? linebuf : (void*)addr;    /* or an if statement */
print_buffer(addr, p, size, linebytes/size,DISP_LINE_LEN/size);

Best Regards
Ulf Samuelsson





More information about the U-Boot mailing list