[PATCH] maple_tree: Use correct variable type in sizeof

Peng Zhang zhangpeng.00 at bytedance.com
Mon Apr 10 03:09:27 PDT 2023


在 2023/4/10 17:46, Gang Li 写道:
> On 2023/4/10 17:14, Peng Zhang wrote:
>> The original code is:
>>     memset(pivs + tmp, 0, sizeof(unsigned long *) * (max_p - tmp));
>>
>> The type of variable pointed to by pivs is unsigned long, but the type
>> used in sizeof is a pointer type. Change it to unsigned long.
>>
>
> Maybe add a fix tag?
>
> Fixes: 54a611b60590 ("Maple Tree: add new data structure")

Maybe sizeof(void *) is equal to sizeof(unsigned long)
in most architectures, so I don't know if it counts as a fix.

Thanks.

>
>> Suggested-by: David Binderman <dcb314 at hotmail.com>
>> Signed-off-by: Peng Zhang <zhangpeng.00 at bytedance.com>
>> ---
>>   lib/maple_tree.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
>> index 88c44f6d6cee..b06fc5f19b31 100644
>> --- a/lib/maple_tree.c
>> +++ b/lib/maple_tree.c
>> @@ -3255,7 +3255,7 @@ static inline void mas_destroy_rebalance(struct 
>> ma_state *mas, unsigned char end
>>             if (tmp < max_p)
>>               memset(pivs + tmp, 0,
>> -                   sizeof(unsigned long *) * (max_p - tmp));
>> +                   sizeof(unsigned long) * (max_p - tmp));
>>             if (tmp < mt_slots[mt])
>>               memset(slots + tmp, 0, sizeof(void *) * (max_s - tmp));
>



More information about the maple-tree mailing list