Re: [RFC PATCH v2 10/15] cpu-model/s390: Add cpu class initialization routines

From: Richard Henderson
Date: Fri Feb 20 2015 - 13:12:05 EST


On 02/17/2015 06:24 AM, Michael Mueller wrote:
> +static inline uint64_t big_endian_bit(unsigned long nr)
> +{
> + return 1ul << (BITS_PER_LONG - (nr % BITS_PER_LONG));
> +};

This is buggy. NR=0 should map to 63, not 64.

> + return !!(*ptr & big_endian_bit(nr));

Personally I dislike !! as an idiom. Given that big_endian_bit isn't used
anywhere else, can we integrate it and change this to

static inline int test_facility(unsigned long nr, uint64_t *fac_list)
{
unsigned long word = nr / BITS_PER_LONG;
unsigned long be_bit = 63 - (nr % BITS_PER_LONG);
return (fac_list[word] >> be_bit) & 1;
}


r~
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/