From: Nick Desaulniers <ndesaulniers@google.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Kentaro Takeda <takedakn@nttdata.co.jp>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
Nathan Chancellor <natechancellor@gmail.com>,
Toshiharu Harada <haradats@nttdata.co.jp>,
Arnd Bergmann <arnd@arndb.de>,
linux-security-module@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>
Subject: Re: [PATCH] tomoyo: fix clang pointer arithmetic warning
Date: Wed, 11 Nov 2020 12:00:37 -0800 [thread overview]
Message-ID: <CAKwvOdnHWYXieOPbOWzXxC_5vLdQdW4FsLZyiMmtzfj6JH4UWA@mail.gmail.com> (raw)
In-Reply-To: <20201026215236.3894200-1-arnd@kernel.org>
On Mon, Oct 26, 2020 at 2:52 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang warns about additions on NULL pointers being undefined in C:
>
> security/tomoyo/securityfs_if.c:226:59: warning: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic]
> securityfs_create_file(name, mode, parent, ((u8 *) NULL) + key,
>
> Change the code to instead use a cast through uintptr_t to avoid
> the warning.
>
> Fixes: 9590837b89aa ("Common functions for TOMOYO Linux.")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Thanks for the patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> security/tomoyo/securityfs_if.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/tomoyo/securityfs_if.c b/security/tomoyo/securityfs_if.c
> index 546281c5b233..0a5f00073ef1 100644
> --- a/security/tomoyo/securityfs_if.c
> +++ b/security/tomoyo/securityfs_if.c
> @@ -223,7 +223,7 @@ static const struct file_operations tomoyo_operations = {
> static void __init tomoyo_create_entry(const char *name, const umode_t mode,
> struct dentry *parent, const u8 key)
> {
> - securityfs_create_file(name, mode, parent, ((u8 *) NULL) + key,
> + securityfs_create_file(name, mode, parent, (u8 *)(uintptr_t)key,
> &tomoyo_operations);
> }
>
> --
> 2.27.0
>
--
Thanks,
~Nick Desaulniers
prev parent reply other threads:[~2020-11-11 20:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-26 21:52 [PATCH] tomoyo: fix clang pointer arithmetic warning Arnd Bergmann
2020-11-11 20:00 ` Nick Desaulniers [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=CAKwvOdnHWYXieOPbOWzXxC_5vLdQdW4FsLZyiMmtzfj6JH4UWA@mail.gmail.com \
--to=ndesaulniers@google.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=clang-built-linux@googlegroups.com \
--cc=haradats@nttdata.co.jp \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=serge@hallyn.com \
--cc=takedakn@nttdata.co.jp \
/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).