Messages in this thread |  | | Date | Mon, 20 Jul 2015 16:28:00 -0700 | | From | Andrew Morton <> | | Subject | Re: [PATCH] iommu-common: Do not use 64 bit constant 0xffffffffffffffffl for computing align_mask |
| |
On Mon, 20 Jul 2015 19:57:18 +0200 Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> On Mon, Jul 20 2015, Guenter Roeck <linux@roeck-us.net> wrote: > > > So either case ~0l appears to be wrong; it should be ~0ul. > > Yes, right-shifting -1 of any type is probably always wrong, as it will > always give -1 again.
Not for unsigned types.
The kernel uses "-1UL" and "-1ULL" quite a lot - it's a convenient way of saying "all ones, regardless of size". Also, assigning plain old "-1" to an unsigned variable will make that variable all-ones regardless of size.
In this case I expect we could do
align_mask = -1UL >> (64 - align_order);
but I don't know about that 64. Maybe it should be BITS_PER_LONG?
|  |