[PATCH v2 1/3] um: virt-pci: fix 32-bit compile

Johannes Berg johannes at sipsolutions.net
Wed Sep 15 12:06:51 PDT 2021


On Wed, 2021-09-15 at 20:42 +0200, Geert Uytterhoeven wrote:
> 
> > -       unsigned long ret = ~0ULL;
> > +       unsigned long ret = ULONG_MAX;
> 
> Why not just drop the last "L"? ;-)
> 
> > 
> >         if (!dev)
> > -               return ~0ULL;
> > +               return ULONG_MAX;
> 
> The first change is not needed.

True, but it seemed inconsistent without that.


> > -       memset(data, 0xff, sizeof(data));
> > +       memset(buf->data, 0xff, sizeof(buf->data));

> The second change is a genuine bug fix, also on 64-bit, which should be
> submitted separately, and backported to stable.

It's kind of a bug, I agree. However:

On 64-bit platforms, the pointer size is 8 bytes, and thus all the data
is memset to 0xff as needed.

On 32-bit platforms, we cannot do 64-bit reads (there's no ioread64 on
32-bit), and thus we can only ever need four 0xff bytes (for a failing
32-bit read), matching the pointer size, so it ends up being correct as
well.

johannes




More information about the linux-um mailing list