[v2,1/2] btrfs: replace INT_LIMIT(loff_t) with OFFSET_MAX

Message ID 20221121024418.1800-2-thunder.leizhen@huawei.com
State New
Headers
Series fs: clear a UBSAN shift-out-of-bounds warning |

Commit Message

Zhen Lei Nov. 21, 2022, 2:44 a.m. UTC
  OFFSET_MAX is self-annotated and more readable.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 fs/btrfs/ordered-data.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

David Sterba Nov. 21, 2022, 5:30 p.m. UTC | #1
On Mon, Nov 21, 2022 at 10:44:17AM +0800, Zhen Lei wrote:
> OFFSET_MAX is self-annotated and more readable.
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

Acked-by: David Sterba <dsterba@suse.com>
  
Eric Biggers Nov. 21, 2022, 7:57 p.m. UTC | #2
On Mon, Nov 21, 2022 at 10:44:17AM +0800, Zhen Lei wrote:
> OFFSET_MAX is self-annotated and more readable.
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
>  fs/btrfs/ordered-data.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
> index e54f8280031fa14..100d9f4836b177d 100644
> --- a/fs/btrfs/ordered-data.c
> +++ b/fs/btrfs/ordered-data.c
> @@ -761,11 +761,11 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
>  	struct btrfs_ordered_extent *ordered;
>  
>  	if (start + len < start) {
> -		orig_end = INT_LIMIT(loff_t);
> +		orig_end = OFFSET_MAX;
>  	} else {
>  		orig_end = start + len - 1;
> -		if (orig_end > INT_LIMIT(loff_t))
> -			orig_end = INT_LIMIT(loff_t);
> +		if (orig_end > OFFSET_MAX)
> +			orig_end = OFFSET_MAX;
>  	}
>  
>  	/* start IO across the range first to instantiate any delalloc
> -- 

Reviewed-by: Eric Biggers <ebiggers@google.com>

- Eric
  

Patch

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index e54f8280031fa14..100d9f4836b177d 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -761,11 +761,11 @@  int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
 	struct btrfs_ordered_extent *ordered;
 
 	if (start + len < start) {
-		orig_end = INT_LIMIT(loff_t);
+		orig_end = OFFSET_MAX;
 	} else {
 		orig_end = start + len - 1;
-		if (orig_end > INT_LIMIT(loff_t))
-			orig_end = INT_LIMIT(loff_t);
+		if (orig_end > OFFSET_MAX)
+			orig_end = OFFSET_MAX;
 	}
 
 	/* start IO across the range first to instantiate any delalloc