[PATCH 6/10] squashfs: conserve stack, remove casts

From: Jörn Engel
Date: Fri Apr 22 2005 - 02:24:30 EST


Jörn

--
All art is but imitation of nature.
-- Lucius Annaeus Seneca


Signed-off-by: Jörn Engel <joern@xxxxxxxxxxxxxxxxxxxx>
---

fs/squashfs/inode.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

--- linux-2.6.12-rc3cow/fs/squashfs/inode.c~squashfs_cu6 2005-04-22 07:21:11.523554656 +0200
+++ linux-2.6.12-rc3cow/fs/squashfs/inode.c 2005-04-22 09:17:45.607292312 +0200
@@ -1405,12 +1405,15 @@ static int get_dir_index_using_name(stru
squashfs_sb_info *msBlk = s->s_fs_info;
squashfs_super_block *sBlk = &msBlk->sBlk;
int i, length = 0;
- char buffer[sizeof(squashfs_dir_index) + SQUASHFS_NAME_LEN + 1];
- squashfs_dir_index *index = (squashfs_dir_index *) buffer;
+ squashfs_dir_index *index;
char str[SQUASHFS_NAME_LEN + 1];

TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count);

+ index = kmalloc(sizeof(*index) + SQUASHFS_NAME_LEN + 1, GFP_KERNEL);
+ if (!index)
+ return -ENOMEM;
+
strncpy(str, name, size);
str[size] = '\0';

@@ -1442,6 +1445,7 @@ static int get_dir_index_using_name(stru
}

*next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
+ kfree(index);
return length;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/