qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/4] net: add FTGMAC100 support


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 1/4] net: add FTGMAC100 support
Date: Wed, 12 Apr 2017 18:37:34 +0100

On 12 April 2017 at 18:29, Cédric Le Goater <address@hidden> wrote:
> On 04/10/2017 03:43 PM, Peter Maydell wrote:
>> On 1 April 2017 at 13:57, Cédric Le Goater <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]