Re: [PATCH nf] netfilter: nf_tables: fix missmatch in big-endian system

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

 



2017-03-09 18:36 GMT+08:00 Arturo Borrero Gonzalez <arturo@xxxxxxxxxx>:
> On 8 March 2017 at 15:54, Liping Zhang <zlpnobody@xxxxxxx> wrote:
>>
>> +/* Store/load an u16 or u8 integer to/from the u32 data register.
>> + *
>> + * Note, when using concatenations, register allocation happens at 32-bit
>> + * level. So for store instruction, pad the rest part with zero to avoid
>> + * garbage values.
>> + */
>> +
>> +static inline void nft_reg_store16(u32 *dreg, u16 val)
>> +{
>> +       *dreg = 0;
>> +       *(u16 *)dreg = val;
>> +}
>> +
>> +static inline void nft_reg_store8(u32 *dreg, u8 val)
>> +{
>> +       *dreg = 0;
>> +       *(u8 *)dreg = val;
>> +}
>> +
>
> Any chance the compiler detects the double assignment and removes the first one?

This will never happen, since these two assignment statements are not identical.
Remove the first one will cause the wrong result.

But if you write:
     *dreg = 0;
     *dreg = val;
Then the compiler will likely to optimize the above codes to just one line:
     *dreg = val;
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux