All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
To: Bart Van Assche <bvanassche@acm.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	<linux-block@vger.kernel.org>, <dhowells@redhat.com>,
	<akpm@linux-foundation.org>, <torvalds@linux-foundation.org>
Cc: <bywxiaobai@163.com>, Mingfangsen <mingfangsen@huawei.com>,
	Guiyao <guiyao@huawei.com>, zhangsaisai <zhangsaisai@huawei.com>,
	renxudong <renxudong1@huawei.com>
Subject: Re: [PATCH] kdev_t: mask mi with MINORMASK in MKDEV macro
Date: Sun, 12 Jan 2020 16:21:41 +0800	[thread overview]
Message-ID: <ec7bb0e3-3064-81a9-0cf2-844f61073f4f@huawei.com> (raw)
In-Reply-To: <d890c06e-5b56-629a-2e9f-bc19209238e4@acm.org>

On 2020/1/11 12:50, Bart Van Assche wrote:
> On 2020-01-09 22:37, Zhiqiang Liu wrote:
>>
>> In MKDEV macro, if mi is larger than MINORMASK, the major will be
>> affected by mi. For example, set dev = MKDEV(2, (1U << MINORBITS)),
>> then MAJOR(dev) will be equal to 3, incorrectly.
>>
>> Here, we mask mi with MINORMASK in MKDEV macro.
>>
>> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> ---
>>  include/linux/kdev_t.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/linux/kdev_t.h b/include/linux/kdev_t.h
>> index 85b5151911cf..40a9423720b2 100644
>> --- a/include/linux/kdev_t.h
>> +++ b/include/linux/kdev_t.h
>> @@ -9,7 +9,7 @@
>>
>>  #define MAJOR(dev)	((unsigned int) ((dev) >> MINORBITS))
>>  #define MINOR(dev)	((unsigned int) ((dev) & MINORMASK))
>> -#define MKDEV(ma,mi)	(((ma) << MINORBITS) | (mi))
>> +#define MKDEV(ma, mi)	(((ma) << MINORBITS) | ((mi) & MINORMASK))
>>
>>  #define print_dev_t(buffer, dev)					\
>>  	sprintf((buffer), "%u:%u\n", MAJOR(dev), MINOR(dev))
> 
> Shouldn't the users of MKDEV() be fixed instead of changing the MKDEV()
> definition?
> 
> Thanks,
> 
> Bart.
Thanks for your reply.
I think that your opinion is much better. Users of MKDEV() should
make sure that the mi is not larger than MINORMASK. If we mask mi with
MINORMASK in MKDEV(), ma will be not affected by mi. But, the result
may be not the expected value of users.

So, please ignore the patch.


> 
> 
> 


      reply	other threads:[~2020-01-12  8:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  6:37 [PATCH] kdev_t: mask mi with MINORMASK in MKDEV macro Zhiqiang Liu
2020-01-11  4:50 ` Bart Van Assche
2020-01-12  8:21   ` Zhiqiang Liu [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=ec7bb0e3-3064-81a9-0cf2-844f61073f4f@huawei.com \
    --to=liuzhiqiang26@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=bvanassche@acm.org \
    --cc=bywxiaobai@163.com \
    --cc=dhowells@redhat.com \
    --cc=guiyao@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingfangsen@huawei.com \
    --cc=renxudong1@huawei.com \
    --cc=torvalds@linux-foundation.org \
    --cc=zhangsaisai@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.