Re: [PATCH] fix expansion of constant bitfield dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Chris,

On 21 August 2017 at 13:26, Christopher Li <sparse@xxxxxxxxxxx> wrote:
> On Sun, Aug 20, 2017 at 6:16 PM, Luc Van Oostenryck
> <luc.vanoostenryck@xxxxxxxxx> wrote:
>> During the expansion of a dereference, it's if the initializer
>> which corrrespond to the offset we're interested is a constant.
>> In which case this dereference can be avoided and the value
>> given in the initializer can be used instead.
>>
>> However, it's not enough to check for the offset since for bitfields
>> several are placed at the same offset.
>> Currently, the first initializer matching the offset is selected.
>>
>> Fix this by refusing such expansion if the constant value correspond
>> to a bitfield.
>>
>
>> --- a/expand.c
>> +++ b/expand.c
>> @@ -644,6 +644,8 @@ static int expand_dereference(struct expression *expr)
>>                 if (value) {
>>                         /* FIXME! We should check that the size is right! */
>>                         if (value->type == EXPR_VALUE) {
>> +                               if (is_bitfield_type(value->ctype))
>> +                                       return UNSAFE;
>
> You might want to consider move this outside of the EXPR_VALUE.
> I assume there is a bug in sparse matching the value to the member
> wrong, it could happen to EXPR_FVALUE as well.
>

Since a bitfield is always integer and this issue is occurring with
bitfields, then I guess this change is correct?

Regards
Dibyendu
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux