diff mbox series

block: Drop unlikely before IS_ERR(_OR_NULL)

Message ID 20190605142428.84784-4-wangkefeng.wang@huawei.com (mailing list archive)
State New, archived
Headers show
Series block: Drop unlikely before IS_ERR(_OR_NULL) | expand

Commit Message

Kefeng Wang June 5, 2019, 2:24 p.m. UTC
IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag,
so no need to do that again from its callers. Drop it.

Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 block/blk-cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jens Axboe June 5, 2019, 2:22 p.m. UTC | #1
On 6/5/19 8:24 AM, Kefeng Wang wrote:
> IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag,
> so no need to do that again from its callers. Drop it.

Applied, thanks.
Enrico Weigelt, metux IT consult June 5, 2019, 6:24 p.m. UTC | #2
On 05.06.19 14:24, Kefeng Wang wrote:

> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index b97b479e4f64..1f7127b03490 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -881,7 +881,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   			blkg_free(new_blkg);
>   		} else {
>   			blkg = blkg_create(pos, q, new_blkg);
> -			if (unlikely(IS_ERR(blkg))) {
> +			if (IS_ERR(blkg)) {
>   				ret = PTR_ERR(blkg);
>   				goto fail_unlock;
>   			}
> 

I think this cocci script should do such things automatically:

virtual patch
virtual context
virtual org
virtual report

@@
expression E;
@@
- unlikely(IS_ERR(E))
+ IS_ERR(E)


Do you already do it this way and have a cocci scrip on the way
to mainline ?


--mtx
Joe Perches June 5, 2019, 6:32 p.m. UTC | #3
On Wed, 2019-06-05 at 18:24 +0000, Enrico Weigelt, metux IT consult
wrote:
> On 05.06.19 14:24, Kefeng Wang wrote:
> 
> > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> > index b97b479e4f64..1f7127b03490 100644
> > --- a/block/blk-cgroup.c
> > +++ b/block/blk-cgroup.c
> > @@ -881,7 +881,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
> >   			blkg_free(new_blkg);
> >   		} else {
> >   			blkg = blkg_create(pos, q, new_blkg);
> > -			if (unlikely(IS_ERR(blkg))) {
> > +			if (IS_ERR(blkg)) {
> >   				ret = PTR_ERR(blkg);
> >   				goto fail_unlock;
> >   			}
> > 
> 
> I think this cocci script should do such things automatically:
> 
> virtual patch
> virtual context
> virtual org
> virtual report
> 
> @@
> expression E;
> @@
> - unlikely(IS_ERR(E))
> + IS_ERR(E)

Likely change all of these too:

$ git grep -P '\blikely.*IS_ERR'
drivers/net/vxlan.c:    if (likely(!IS_ERR(rt))) {
fs/ntfs/lcnalloc.c:     if (likely(page && !IS_ERR(page))) {
fs/ntfs/mft.c:  if (likely(!IS_ERR(page))) {
fs/ntfs/mft.c:  if (likely(!IS_ERR(m)))
fs/ntfs/mft.c:          if (likely(!IS_ERR(m))) {
fs/ntfs/mft.c:          if (likely(!IS_ERR(rl2)))
fs/ntfs/namei.c:                if (likely(!IS_ERR(dent_inode))) {
fs/ntfs/runlist.c:      if (likely(!IS_ERR(old_rl)))
net/openvswitch/datapath.c:             if (likely(!IS_ERR(reply))) {
net/socket.c:   if (likely(!IS_ERR(newfile))) {
Enrico Weigelt, metux IT consult June 5, 2019, 8:55 p.m. UTC | #4
On 05.06.19 18:32, Joe Perches wrote:

> Likely change all of these too:
> 
> $ git grep -P '\blikely.*IS_ERR'
> drivers/net/vxlan.c:    if (likely(!IS_ERR(rt))) {
> fs/ntfs/lcnalloc.c:     if (likely(page && !IS_ERR(page))) {
> fs/ntfs/mft.c:  if (likely(!IS_ERR(page))) {
> fs/ntfs/mft.c:  if (likely(!IS_ERR(m)))
> fs/ntfs/mft.c:          if (likely(!IS_ERR(m))) {
> fs/ntfs/mft.c:          if (likely(!IS_ERR(rl2)))
> fs/ntfs/namei.c:                if (likely(!IS_ERR(dent_inode))) {
> fs/ntfs/runlist.c:      if (likely(!IS_ERR(old_rl)))
> net/openvswitch/datapath.c:             if (likely(!IS_ERR(reply))) {
> net/socket.c:   if (likely(!IS_ERR(newfile))) {

Good point, thx.

Added that to my cocci script, which I've just sent to lkml.


--mtx
diff mbox series

Patch

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index b97b479e4f64..1f7127b03490 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -881,7 +881,7 @@  int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 			blkg_free(new_blkg);
 		} else {
 			blkg = blkg_create(pos, q, new_blkg);
-			if (unlikely(IS_ERR(blkg))) {
+			if (IS_ERR(blkg)) {
 				ret = PTR_ERR(blkg);
 				goto fail_unlock;
 			}