Dear Stefan Roese, In message <1288343093-31276-1-git-send-email...@denx.de> you wrote: > Until now ubifsload pads the destination with 0 up to a multiple of > UBIFS_BLOCK_SIZE (4KiB) while reading a file to memory. This patch > changes this behaviour to only read to the requested length. This > is either the file length or the length/size provided as parameter > to the ubifsload command. > > Signed-off-by: Stefan Roese <s...@denx.de> > --- > This patch makes the patch [UBIFS: Add padded size to ubifsload output] > posted yesterday obsolete since we're not padding any more now. ... > + /* > + * We need to buffer the data locally for the > + * last block. This is to not pad the > destination > + * area to a multiple of UBIFS_BLOCK_SIZE. > + */ > + buff = malloc(UBIFS_BLOCK_SIZE); > + > + /* Read block-siez into temp buffer */ > + ret = read_block(inode, buff, block, dn); > + if (last_block_size) > + dlen = last_block_size; > + else > + dlen = le32_to_cpu(dn->size);
How about some error handling? malloc() can fail, and read_block() can fail as well. > + /* Now copy required size back to dest */ > + memcpy(addr, buff, dlen); > + > + free(buff); > + } else { > + ret = read_block(inode, addr, block, dn); > + if (ret) { > + err = ret; > + if (err != -ENOENT) > + break; or simpler: ret = read_block(inode, addr, block, dn); if (ret != -ENOENT) { err = ret; break; } 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: w...@denx.de "I used to think that the brain was the most wonderful organ in my body. Then I realized who was telling me this." - Emo Phillips _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot