mirror of https://gitee.com/openkylin/linux.git
ext4: use variables not types in sizeofs() for allocations
Precursor to changing some types; to keep things in sync, it seems better to allocate/memset based on the size of the variables we are using rather than on some disconnected basic type like "unsigned short" Signed-off-by: Eric Sandeen <sandeen@redhat.com>
This commit is contained in:
parent
a8526e84ac
commit
1927805e65
|
@ -868,7 +868,8 @@ static int ext4_mb_init_cache(struct page *page, char *incore)
|
||||||
grinfo = ext4_get_group_info(sb, group);
|
grinfo = ext4_get_group_info(sb, group);
|
||||||
grinfo->bb_fragments = 0;
|
grinfo->bb_fragments = 0;
|
||||||
memset(grinfo->bb_counters, 0,
|
memset(grinfo->bb_counters, 0,
|
||||||
sizeof(unsigned short)*(sb->s_blocksize_bits+2));
|
sizeof(*grinfo->bb_counters) *
|
||||||
|
(sb->s_blocksize_bits+2));
|
||||||
/*
|
/*
|
||||||
* incore got set to the group block bitmap below
|
* incore got set to the group block bitmap below
|
||||||
*/
|
*/
|
||||||
|
@ -2640,14 +2641,14 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
|
||||||
unsigned max;
|
unsigned max;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
i = (sb->s_blocksize_bits + 2) * sizeof(unsigned short);
|
i = (sb->s_blocksize_bits + 2) * sizeof(*sbi->s_mb_offsets);
|
||||||
|
|
||||||
sbi->s_mb_offsets = kmalloc(i, GFP_KERNEL);
|
sbi->s_mb_offsets = kmalloc(i, GFP_KERNEL);
|
||||||
if (sbi->s_mb_offsets == NULL) {
|
if (sbi->s_mb_offsets == NULL) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = (sb->s_blocksize_bits + 2) * sizeof(unsigned int);
|
i = (sb->s_blocksize_bits + 2) * sizeof(*sbi->s_mb_maxs);
|
||||||
sbi->s_mb_maxs = kmalloc(i, GFP_KERNEL);
|
sbi->s_mb_maxs = kmalloc(i, GFP_KERNEL);
|
||||||
if (sbi->s_mb_maxs == NULL) {
|
if (sbi->s_mb_maxs == NULL) {
|
||||||
kfree(sbi->s_mb_offsets);
|
kfree(sbi->s_mb_offsets);
|
||||||
|
|
Loading…
Reference in New Issue