On 12 April 2017 at 18:29, Cédric Le Goater <c...@kaod.org> wrote:
> On 04/10/2017 03:43 PM, Peter Maydell wrote:
>> On 1 April 2017 at 13:57, Cédric Le Goater <c...@kaod.org> wrote:
>>> +    case FTGMAC100_MAC_LADR:
>>> +        return (s->conf.macaddr.a[2] << 24) | (s->conf.macaddr.a[3] << 16) 
>>> |
>>> +               (s->conf.macaddr.a[4] << 8)  |  s->conf.macaddr.a[5];
>>
>> This will sign extend the high bit of macaddr.a[2] into bits 63..32 of
>> the return value, which probably isn't what you intended and will
>> make Coverity unhapppy.
>
> indeed. What would you recommand ? simply :
>
>         ((uint64_t) s->conf.macaddr.a[2] << 24) | ...

Cast to uint32_t is sufficient. We just need to avoid ending
up with a signed 32 bit value...

thanks
-- PMM

Reply via email to