linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Vasily Averin <vvs@openvz.org>
Cc: Christoph Hellwig <hch@infradead.org>,
	kernel@openvz.org, linux-kernel@vger.kernel.org,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3] fs/proc/base.c: fix incorrect fmode_t casts
Date: Mon, 23 May 2022 00:04:43 +0100	[thread overview]
Message-ID: <YorBiz6QA0JBVta/@casper.infradead.org> (raw)
In-Reply-To: <31a6874c-1cb8-e081-f1ca-ef1a81f9dda0@openvz.org>

On Sun, May 22, 2022 at 03:08:42PM +0300, Vasily Averin wrote:
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index c1031843cc6a..4e4edf9db5f0 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -2237,13 +2237,13 @@ static struct dentry *
>  proc_map_files_instantiate(struct dentry *dentry,
>  			   struct task_struct *task, const void *ptr)
>  {
> -	fmode_t mode = (fmode_t)(unsigned long)ptr;
> +	const fmode_t *mode = ptr;

Why not ...

	fmode_t mode = *(fmode_t *)ptr;

and then you don't need

> -				    ((mode & FMODE_READ ) ? S_IRUSR : 0) |
> -				    ((mode & FMODE_WRITE) ? S_IWUSR : 0));
> +				    ((*mode & FMODE_READ ) ? S_IRUSR : 0) |
> +				    ((*mode & FMODE_WRITE) ? S_IWUSR : 0));

  parent reply	other threads:[~2022-05-22 23:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-22 12:08 [PATCH v3] fs/proc/base.c: fix incorrect fmode_t casts Vasily Averin
2022-05-22 12:09 ` Christoph Hellwig
2022-05-22 23:04 ` Matthew Wilcox [this message]
2022-05-23  3:37   ` [PATCH v4] " Vasily Averin
2022-05-23  3:48     ` Matthew Wilcox
2022-05-23  9:40     ` Christian Brauner

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=YorBiz6QA0JBVta/@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=brauner@kernel.org \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=kernel@openvz.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vvs@openvz.org \
    /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).