mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Jagan Teki <jteki@openedev.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Wolfram Sang <wsa@the-dreams.de>
Subject: Re: [PATCH] block: Use BIT macro from include/linux/bitops.h
Date: Wed, 20 May 2015 13:52:55 -0600	[thread overview]
Message-ID: <555CE617.2040201@kernel.dk> (raw)
In-Reply-To: <CAD6G_RRwnCpMsRQg97rebuQq3PxoKxFKj9vfZsXH+J62TBE-WQ@mail.gmail.com>

On 05/20/2015 01:50 PM, Jagan Teki wrote:
> On 21 May 2015 at 01:13, Jens Axboe <axboe@kernel.dk> wrote:
>> On 05/20/2015 01:41 PM, Jagan Teki wrote:
>>>
>>> On 21 May 2015 at 00:52, Jens Axboe <axboe@kernel.dk> wrote:
>>>>
>>>> On 05/18/2015 01:14 PM, Jagan Teki wrote:
>>>>>
>>>>>
>>>>> Replace (1 << nr) to BIT(nr) where nr = 0, 1, 2 .... 31
>>>>
>>>>
>>>>
>>>> I don't like it, I think it hurts readability.
>>>
>>>
>>> What do you mean by don't like, using kernel defined macro instead of
>>> numerical assignments huts readability?
>>
>>
>> In the context of the patch, BIT(0) == (1 << 0) is obvious. But if I just
>> came across BIT(7) in the code, I'd have to check, whereas anyone would
>> immediately know that (1 << 7) is the 7th bit set. Hence, readability is
>> worse, and that's important.
>
> I don't how that BIT(7) is tricky to understand as BIT(0) implies to
> be set 0th bit.
> If understanding of BIT(0) is same like to be as BIT(7) and these were
> simplified
> macro's used most of the code in kernel.

Well of course, if you know what BIT(7) is, you know what BIT(0) is. My 
point is that I don't know what either of them are, I'd have to look it 
up. Whereas anyone would immediately know what (1 << 7) or (1 << 0) is 
without having to look further.


-- 
Jens Axboe


      reply	other threads:[~2015-05-20 19:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 19:14 Jagan Teki
2015-05-20 18:43 ` Jagan Teki
2015-05-20 19:22 ` Jens Axboe
2015-05-20 19:41   ` Jagan Teki
2015-05-20 19:43     ` Jens Axboe
2015-05-20 19:50       ` Jagan Teki
2015-05-20 19:52         ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=555CE617.2040201@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=jteki@openedev.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome