
* Fix indent * Read inode size only once, as it can be reused
Signed-off-by: Marek Vasut marex@denx.de Cc: Wolfgang Denk wd@denx.de --- fs/ext2/ext2fs.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c index 0d54ae6..22cc9c2 100644 --- a/fs/ext2/ext2fs.c +++ b/fs/ext2/ext2fs.c @@ -458,35 +458,36 @@ static char *ext2fs_read_symlink(struct ext2fs_node *node) char *symlink; struct ext2fs_node *diro = node; int status; + uint32_t size;
if (!diro->inode_read) { - status = ext2fs_read_inode (diro->data, diro->ino, - &diro->inode); - if (status == 0) { - return (0); - } - } - symlink = malloc (__le32_to_cpu (diro->inode.size) + 1); - if (!symlink) { - return (0); + status = ext2fs_read_inode(diro->data, diro->ino, &diro->inode); + if (status == 0) + return 0; } - /* If the filesize of the symlink is bigger than - 60 the symlink is stored in a separate block, - otherwise it is stored in the inode. */ - if (__le32_to_cpu (diro->inode.size) <= 60) { - strncpy (symlink, diro->inode.b.symlink, - __le32_to_cpu (diro->inode.size)); + + size = __le32_to_cpu(diro->inode.size); + symlink = malloc(size + 1); + if (!symlink) + return 0; + + /* + * If the filesize of the symlink is bigger than 60 the symlink is + * stored in a separate block, otherwise it is stored in the inode. + */ + if (size <= 60) { + strncpy(symlink, diro->inode.b.symlink, size); } else { - status = ext2fs_read_file (diro, 0, - __le32_to_cpu (diro->inode.size), - symlink); + status = ext2fs_read_file(diro, 0, size, symlink); if (status == 0) { - free (symlink); - return (0); + free(symlink); + return 0; } } - symlink[__le32_to_cpu (diro->inode.size)] = '\0'; - return (symlink); + + symlink[size] = '\0'; + + return symlink; }
int ext2fs_find_file1