All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: oe-kbuild@lists.linux.dev, Hugh Dickins <hughd@google.com>,
	lkp@intel.com,  oe-kbuild-all@lists.linux.dev,
	 Christian Brauner <christianvanbrauner@gmail.com>,
	 Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Subject: Re: [brauner-vfs:vfs.tmpfs 15/19] mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
Date: Thu, 10 Aug 2023 23:43:29 -0700 (PDT)	[thread overview]
Message-ID: <baf5ac73-23b4-e325-28e5-9547af7ec3a@google.com> (raw)
In-Reply-To: <dd00b419-ca16-48fb-b493-890ab47cc930@kadam.mountain>

On Fri, 11 Aug 2023, Dan Carpenter wrote:
...
> smatch warnings:
> mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
...
> 46170cc50828c3 Hugh Dickins        2023-08-08  3604  	old_xattr = simple_xattr_set(&info->xattrs, name, value, size, flags);
> 46170cc50828c3 Hugh Dickins        2023-08-08  3605  	if (!IS_ERR(old_xattr)) {
> 46170cc50828c3 Hugh Dickins        2023-08-08  3606  		simple_xattr_free(old_xattr);
> 46170cc50828c3 Hugh Dickins        2023-08-08  3607  		old_xattr = NULL;
> 36f05cab0a2c97 Jeff Layton         2022-09-09  3608  		inode->i_ctime = current_time(inode);
> 36f05cab0a2c97 Jeff Layton         2022-09-09  3609  		inode_inc_iversion(inode);
> 36f05cab0a2c97 Jeff Layton         2022-09-09  3610  	}
> 46170cc50828c3 Hugh Dickins        2023-08-08 @3611  	return PTR_ERR(old_xattr);
> 
> This code is correct but it would be nicer to reverse the checking:
> 
> 	old_xattr = simple_xattr_set(&info->xattrs, name, value, size, flags);
> 	if (IS_ERR(old_xattr))
> 		return PTR_ERR(old_xattr);
> 
> 	simple_xattr_free(old_xattr);
> 	inode->i_ctime = current_time(inode);
> 	inode_inc_iversion(inode);
> 
> 	return 0;

Thanks, Dan, but I'm going to resist making any change here.

As you observe, the code is correct as is.  And I did have a version
(unposted) which laid it out exactly as you have it there.  But the
collisions between different branches of vfs.git (and subsequent mods
here in vfs.tmpfs) was such that I aimed to minimize the interference.

Please let's leave it as is: there is nothing wrong with PTR_ERR(NULL).

Hugh

  reply	other threads:[~2023-08-11  6:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11  5:26 [brauner-vfs:vfs.tmpfs 15/19] mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR' Dan Carpenter
2023-08-11  6:43 ` Hugh Dickins [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-08-11 21:15 kernel test robot
2023-08-11  2:49 kernel test robot

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=baf5ac73-23b4-e325-28e5-9547af7ec3a@google.com \
    --to=hughd@google.com \
    --cc=brauner@kernel.org \
    --cc=christianvanbrauner@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=jack@suse.cz \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    /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.