Re: [PATCH] usb: dwc3: Simplify memset struct array
From: Zijun Hu
Date: Thu Apr 10 2025 - 20:08:10 EST
On 2025/4/11 01:02, Greg Kroah-Hartman wrote:
>> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
>> index b48e108fc8fe7343446946e7babf9ba3bc0d2dc3..5a2fe4c6b0e433c32945c136b8b35e1912e3acc8 100644
>> --- a/drivers/usb/dwc3/host.c
>> +++ b/drivers/usb/dwc3/host.c
>> @@ -158,7 +158,7 @@ int dwc3_host_init(struct dwc3 *dwc)
>> goto err;
>> }
>>
>> - memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props));
>> + memset(props, 0, sizeof(props));
> What does this really help with? It feels like churn to me.
just code in an even more concise way.
for "struct property_entry props[6]", what is your preference to
memset it ?
A) memset(props, 0, sizeof(props));
B) memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props));
drivers/usb/* have 5 usages as B).
is it worthy of a patch to simplify them if you prefer A) ?