linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Zhiqiang Liu <liuzhiqiang26@huawei.com>,
	"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: Fri, 10 Jan 2020 20:50:53 -0800	[thread overview]
Message-ID: <d890c06e-5b56-629a-2e9f-bc19209238e4@acm.org> (raw)
In-Reply-To: <5d384dcb-5590-60f8-a4e1-efa6b8da151f@huawei.com>

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.



  reply	other threads:[~2020-01-11  4:50 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 [this message]
2020-01-12  8:21   ` Zhiqiang Liu

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=d890c06e-5b56-629a-2e9f-bc19209238e4@acm.org \
    --to=bvanassche@acm.org \
    --cc=akpm@linux-foundation.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=liuzhiqiang26@huawei.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).