Skip to content

Commit

Permalink
tomoyo: fix clang pointer arithmetic warning
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
  • Loading branch information
arndb authored and Tetsuo Handa committed Oct 28, 2020
1 parent d4fe911 commit d9594e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions security/tomoyo/securityfs_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ static const struct file_operations tomoyo_self_operations = {
*/
static int tomoyo_open(struct inode *inode, struct file *file)
{
const int key = ((u8 *) file_inode(file)->i_private)
- ((u8 *) NULL);
const u8 key = (uintptr_t) file_inode(file)->i_private;

return tomoyo_open_control(key, file);
}

Expand Down Expand Up @@ -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, (void *) (uintptr_t) key,
&tomoyo_operations);
}

Expand Down

0 comments on commit d9594e0

Please sign in to comment.