lkml.org 
[lkml]   [2022]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] fs/proc/base.c: fix incorrect fmode_t casts
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));

\
 
 \ /
  Last update: 2022-05-23 01:05    [W:0.055 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site