Re: [PATCH] staging: lustre: Replace a bit shift by a use of BIT.

From: Dilger, Andreas
Date: Thu Mar 23 2017 - 16:45:34 EST


On Mar 22, 2017, at 06:12, Dilger, Andreas <andreas.dilger@xxxxxxxxx> wrote:
>
> On Mar 21, 2017, at 22:39, Arushi Singhal <arushisinghal19971997@xxxxxxxxx> wrote:
>>
>> This patch replaces bit shifting on 1 with the BIT(x) macro.
>> This was done with coccinelle:
[snip]
>> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
>> index 18183cbb9859..e83761a77d22 100644
>> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
>> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
>> @@ -997,10 +997,10 @@ lnet_fault_ctl(int opc, struct libcfs_ioctl_data *data)
>> int
>> lnet_fault_init(void)
>> {
>> - BUILD_BUG_ON(LNET_PUT_BIT != 1 << LNET_MSG_PUT);
>> - BUILD_BUG_ON(LNET_ACK_BIT != 1 << LNET_MSG_ACK);
>> - BUILD_BUG_ON(LNET_GET_BIT != 1 << LNET_MSG_GET);
>> - BUILD_BUG_ON(LNET_REPLY_BIT != 1 << LNET_MSG_REPLY);
>> + BUILD_BUG_ON(LNET_PUT_BIT != BIT(LNET_MSG_PUT));
>> + BUILD_BUG_ON(LNET_ACK_BIT != BIT(LNET_MSG_ACK));
>> + BUILD_BUG_ON(LNET_GET_BIT != BIT(LNET_MSG_GET));
>> + BUILD_BUG_ON(LNET_REPLY_BIT != BIT(LNET_MSG_REPLY));
>
> This looks reasonable at first glance, though on further thought it seems kind of
> pointless since this is really:
>
> #defined LET_PUT_BIT BIT(LNET_MSG_PUT)
>
> BUILD_BUG_ON(BIT(LNET_MSG_PUT) != BIT(LNET_MSG_PUT))
>
> so it is just checking that the macro's value is the same when called two times.
> I'd suggest just getting rid of these BUILD_BUG_ON() checks completely .

Arushi, it would be great if you could submit a patch to remove the above
BUILD_BUG_ON() lines completely. I don't think they have any value anymore.

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation