[PATCH] staging: rtl8192u: initialize array in C compliant way

Christopher Li sparse at chrisli.org
Sat May 10 09:09:52 UTC 2014


On Tue, May 6, 2014 at 1:47 AM, Dan Carpenter <dan.carpenter at oracle.com> wrote:
>> diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
>> index 426f223..c96dbab 100644
>> --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
>> +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
>> @@ -241,7 +241,7 @@ static PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee,
>>  {
>>       //DIRECTION_VALUE       dir;
>>       u8      dir;
>> -     bool                            search_dir[4] = {0, 0, 0, 0};
>> +     bool                            search_dir[4] = {0};
>
> That's weird.  The original code is valid but it generates a sparse
> warning.

Sorry for the late reply. I see what is going on already. The bits_to_bytes()
function is buggy for bool type. Bool is the only type has bits less than 8.
It truncates the bool byte size to 0. As a result, the array layout function
convert_index() always set the expr->init_offset to 0 for bool type:

"e->init_offset = from * bits_to_bytes(e->ctype->bit_size);"

Chris


More information about the devel mailing list