[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201027104450.GA8864@infradead.org>
Date: Tue, 27 Oct 2020 10:44:50 +0000
From: Christoph Hellwig <hch@...radead.org>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Tejun Heo <tj@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Nathan Chancellor <natechancellor@...il.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Arnd Bergmann <arnd@...db.de>,
Amir Goldstein <amir73il@...il.com>, Jan Kara <jack@...e.cz>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
clang-built-linux@...glegroups.com
Subject: Re: [PATCH] seq_file: fix clang warning for NULL pointer arithmetic
> index f277d023ebcd..b55e6ef4d677 100644
> --- a/fs/kernfs/file.c
> +++ b/fs/kernfs/file.c
> @@ -124,7 +124,7 @@ static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos)
> * The same behavior and code as single_open(). Returns
> * !NULL if pos is at the beginning; otherwise, NULL.
> */
> - return NULL + !*ppos;
> + return (void *)(uintptr_t)!*ppos;
Yikes. This is just horrible, why bnot the completely obvious:
if (ops->seq_start) {
...
return next;
}
if (*ppos)
return NULL;
return ppos; /* random cookie */
> static void *single_start(struct seq_file *p, loff_t *pos)
> {
> - return NULL + (*pos == 0);
> + return (void *)(uintptr_t)(*pos == 0);
Same here.
Powered by blists - more mailing lists