[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPjX3Fdor0TgkQtb2meJD4PFerOQV1Qcjs5HEyBCt5TNt8-vsA@mail.gmail.com>
Date: Wed, 23 Apr 2025 11:48:01 +0200
From: Daniel Vacek <neelx@...e.com>
To: Filipe Manana <fdmanana@...nel.org>
Cc: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>, David Sterba <dsterba@...e.com>,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btrfs: fiemap: make the assert more explicit after
handling the error cases
On Wed, 23 Apr 2025 at 11:04, Filipe Manana <fdmanana@...nel.org> wrote:
>
> On Wed, Apr 23, 2025 at 9:10 AM Daniel Vacek <neelx@...e.com> wrote:
> >
> > Let's not assert the errors and clearly state the expected result only
> > after eventual error handling. It makes a bit more sense this way.
>
> It doesn't make more sense to me...
> I prefer to assert expected results right after the function call.
Oh well, if an error is expected then I get it. Is an error likely
here? I understood the comment says there can't be a file extent item
at offset (u64)-1 which implies a strict return value of 1 and not an
error or something >1. So that's why. And it's still quite after the
function call.
But I'm happy to scratch it if you don't like it.
> Thanks.
>
> >
> > Signed-off-by: Daniel Vacek <neelx@...e.com>
> > ---
> > fs/btrfs/fiemap.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/btrfs/fiemap.c b/fs/btrfs/fiemap.c
> > index b80c07ad8c5e7..034f832e10c1a 100644
> > --- a/fs/btrfs/fiemap.c
> > +++ b/fs/btrfs/fiemap.c
> > @@ -568,10 +568,10 @@ static int fiemap_find_last_extent_offset(struct btrfs_inode *inode,
> > * there might be preallocation past i_size.
> > */
> > ret = btrfs_lookup_file_extent(NULL, root, path, ino, (u64)-1, 0);
> > - /* There can't be a file extent item at offset (u64)-1 */
> > - ASSERT(ret != 0);
> > if (ret < 0)
> > return ret;
> > + /* There can't be a file extent item at offset (u64)-1 */
> > + ASSERT(ret == 1);
> >
> > /*
> > * For a non-existing key, btrfs_search_slot() always leaves us at a
> > --
> > 2.47.2
> >
> >
Powered by blists - more mailing lists