linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: change return value of xfs_inode_need_cow to int
@ 2019-12-23  7:56 zhengbin
  2019-12-23 17:32 ` Darrick J. Wong
  0 siblings, 1 reply; 4+ messages in thread
From: zhengbin @ 2019-12-23  7:56 UTC (permalink / raw)
  To: darrick.wong, linux-xfs; +Cc: zhengbin13

Fixes coccicheck warning:

fs/xfs/xfs_reflink.c:236:9-10: WARNING: return of 0/1 in function 'xfs_inode_need_cow' with return type bool

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 fs/xfs/xfs_reflink.c | 2 +-
 fs/xfs/xfs_reflink.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index de45123..21eeb94 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -223,7 +223,7 @@ xfs_reflink_trim_around_shared(
 	}
 }

-bool
+int
 xfs_inode_need_cow(
 	struct xfs_inode	*ip,
 	struct xfs_bmbt_irec	*imap,
diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h
index d18ad7f..9a288b2 100644
--- a/fs/xfs/xfs_reflink.h
+++ b/fs/xfs/xfs_reflink.h
@@ -22,7 +22,7 @@ extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp,
 		xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal);
 extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
 		struct xfs_bmbt_irec *irec, bool *shared);
-bool xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
+int xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
 		bool *shared);

 int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
--
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xfs: change return value of xfs_inode_need_cow to int
  2019-12-23  7:56 [PATCH] xfs: change return value of xfs_inode_need_cow to int zhengbin
@ 2019-12-23 17:32 ` Darrick J. Wong
  2020-01-19  9:04   ` zhengbin (A)
  0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2019-12-23 17:32 UTC (permalink / raw)
  To: zhengbin; +Cc: linux-xfs

On Mon, Dec 23, 2019 at 03:56:16PM +0800, zhengbin wrote:
> Fixes coccicheck warning:
> 
> fs/xfs/xfs_reflink.c:236:9-10: WARNING: return of 0/1 in function 'xfs_inode_need_cow' with return type bool
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  fs/xfs/xfs_reflink.c | 2 +-
>  fs/xfs/xfs_reflink.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index de45123..21eeb94 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -223,7 +223,7 @@ xfs_reflink_trim_around_shared(
>  	}
>  }
> 
> -bool
> +int
>  xfs_inode_need_cow(

I started to think "just fix this predicate so it doesn't return 1--"

But then I realized that this is /not/ an inode predicate, it's a
reflink trim wrapper for block mappings.  "xfs_bmap_trim_cow" is a
somewhat better name, so I'll commit this with a name change.

And yeah, we turned negative errno into bool and back to int.  Wow.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

>  	struct xfs_inode	*ip,
>  	struct xfs_bmbt_irec	*imap,
> diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h
> index d18ad7f..9a288b2 100644
> --- a/fs/xfs/xfs_reflink.h
> +++ b/fs/xfs/xfs_reflink.h
> @@ -22,7 +22,7 @@ extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp,
>  		xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal);
>  extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
>  		struct xfs_bmbt_irec *irec, bool *shared);
> -bool xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
> +int xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
>  		bool *shared);
> 
>  int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
> --
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xfs: change return value of xfs_inode_need_cow to int
  2019-12-23 17:32 ` Darrick J. Wong
@ 2020-01-19  9:04   ` zhengbin (A)
  2020-01-20 22:34     ` Darrick J. Wong
  0 siblings, 1 reply; 4+ messages in thread
From: zhengbin (A) @ 2020-01-19  9:04 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs


On 2019/12/24 1:32, Darrick J. Wong wrote:
> On Mon, Dec 23, 2019 at 03:56:16PM +0800, zhengbin wrote:
>> Fixes coccicheck warning:
>>
>> fs/xfs/xfs_reflink.c:236:9-10: WARNING: return of 0/1 in function 'xfs_inode_need_cow' with return type bool
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: zhengbin <zhengbin13@huawei.com>
>> ---
>>  fs/xfs/xfs_reflink.c | 2 +-
>>  fs/xfs/xfs_reflink.h | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
>> index de45123..21eeb94 100644
>> --- a/fs/xfs/xfs_reflink.c
>> +++ b/fs/xfs/xfs_reflink.c
>> @@ -223,7 +223,7 @@ xfs_reflink_trim_around_shared(
>>  	}
>>  }
>>
>> -bool
>> +int
>>  xfs_inode_need_cow(
> I started to think "just fix this predicate so it doesn't return 1--"
>
> But then I realized that this is /not/ an inode predicate, it's a
> reflink trim wrapper for block mappings.  "xfs_bmap_trim_cow" is a
> somewhat better name, so I'll commit this with a name change.
>
> And yeah, we turned negative errno into bool and back to int.  Wow.
>
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Does this apply? I do not see it in linux-next
>
> --D
>
>>  	struct xfs_inode	*ip,
>>  	struct xfs_bmbt_irec	*imap,
>> diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h
>> index d18ad7f..9a288b2 100644
>> --- a/fs/xfs/xfs_reflink.h
>> +++ b/fs/xfs/xfs_reflink.h
>> @@ -22,7 +22,7 @@ extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp,
>>  		xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal);
>>  extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
>>  		struct xfs_bmbt_irec *irec, bool *shared);
>> -bool xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
>> +int xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
>>  		bool *shared);
>>
>>  int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
>> --
>> 2.7.4
>>
> .
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xfs: change return value of xfs_inode_need_cow to int
  2020-01-19  9:04   ` zhengbin (A)
@ 2020-01-20 22:34     ` Darrick J. Wong
  0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2020-01-20 22:34 UTC (permalink / raw)
  To: zhengbin (A); +Cc: linux-xfs

On Sun, Jan 19, 2020 at 05:04:38PM +0800, zhengbin (A) wrote:
> 
> On 2019/12/24 1:32, Darrick J. Wong wrote:
> > On Mon, Dec 23, 2019 at 03:56:16PM +0800, zhengbin wrote:
> >> Fixes coccicheck warning:
> >>
> >> fs/xfs/xfs_reflink.c:236:9-10: WARNING: return of 0/1 in function 'xfs_inode_need_cow' with return type bool
> >>
> >> Reported-by: Hulk Robot <hulkci@huawei.com>
> >> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> >> ---
> >>  fs/xfs/xfs_reflink.c | 2 +-
> >>  fs/xfs/xfs_reflink.h | 2 +-
> >>  2 files changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> >> index de45123..21eeb94 100644
> >> --- a/fs/xfs/xfs_reflink.c
> >> +++ b/fs/xfs/xfs_reflink.c
> >> @@ -223,7 +223,7 @@ xfs_reflink_trim_around_shared(
> >>  	}
> >>  }
> >>
> >> -bool
> >> +int
> >>  xfs_inode_need_cow(
> > I started to think "just fix this predicate so it doesn't return 1--"
> >
> > But then I realized that this is /not/ an inode predicate, it's a
> > reflink trim wrapper for block mappings.  "xfs_bmap_trim_cow" is a
> > somewhat better name, so I'll commit this with a name change.
> >
> > And yeah, we turned negative errno into bool and back to int.  Wow.
> >
> > Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> Does this apply? I do not see it in linux-next

Errr, oops.  I forgot to put this in my branch.  Sorry about that. :/

--D

> >
> > --D
> >
> >>  	struct xfs_inode	*ip,
> >>  	struct xfs_bmbt_irec	*imap,
> >> diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h
> >> index d18ad7f..9a288b2 100644
> >> --- a/fs/xfs/xfs_reflink.h
> >> +++ b/fs/xfs/xfs_reflink.h
> >> @@ -22,7 +22,7 @@ extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp,
> >>  		xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal);
> >>  extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
> >>  		struct xfs_bmbt_irec *irec, bool *shared);
> >> -bool xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
> >> +int xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
> >>  		bool *shared);
> >>
> >>  int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap,
> >> --
> >> 2.7.4
> >>
> > .
> >
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-20 22:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-23  7:56 [PATCH] xfs: change return value of xfs_inode_need_cow to int zhengbin
2019-12-23 17:32 ` Darrick J. Wong
2020-01-19  9:04   ` zhengbin (A)
2020-01-20 22:34     ` Darrick J. Wong

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).