All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, linux-security-module@vger.kernel.org
Subject: Re: [PATCH] tomoyo: fix clang pointer arithmetic warning
Date: Wed, 28 Oct 2020 22:22:59 +0900	[thread overview]
Message-ID: <7bb56fd2-ffe2-2985-19d0-31b42bc9e7e8@i-love.sakura.ne.jp> (raw)
In-Reply-To: <20201026215236.3894200-1-arnd@kernel.org>

Thank you for a patch. I have two questions.

On 2020/10/27 6:52, Arnd Bergmann 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.
> 

> -	securityfs_create_file(name, mode, parent, ((u8 *) NULL) + key,
> +	securityfs_create_file(name, mode, parent, (u8 *)(uintptr_t)key,
>  			       &tomoyo_operations);

(1) Does clang warn if "(void *)key" is used instead of "(u8 *)(uintptr_t)key" ?

(2) tomoyo_open() has

	const int key = ((u8 *) file_inode(file)->i_private) - ((u8 *) NULL);

    which decodes the "u8 key" passed to tomoyo_create_entry(). For symmetry,
    I'd like to remove NULL from tomoyo_open() as well. Does clang warn if

	const int key = (u8) (file_inode(file)->i_private);

    is used?

  reply	other threads:[~2020-10-28 23:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 21:52 [PATCH] tomoyo: fix clang pointer arithmetic warning Arnd Bergmann
2020-10-28 13:22 ` Tetsuo Handa [this message]
2020-10-28 13:57   ` Arnd Bergmann
2020-10-28 14:18     ` Tetsuo Handa
2020-11-11 20:00 ` Nick Desaulniers

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=7bb56fd2-ffe2-2985-19d0-31b42bc9e7e8@i-love.sakura.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=linux-security-module@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.