On Tue, Oct 01, 2024 at 10:56:45AM GMT, Dan Carpenter wrote:
> Hello Kent Overstreet,
>
> Commit a6508079b1b6 ("bcachefs: dirent_points_to_inode() now warns on
> mismatch") from Sep 23, 2024 (linux-next), leads to the following
> Smatch static checker warning:
>
> fs/bcachefs/fsck.c:38 dirent_points_to_inode_nowarn()
> warn: signedness bug returning '(-2157)'
>
> fs/bcachefs/fsck.c
> 31 static bool dirent_points_to_inode_nowarn(struct bkey_s_c_dirent d,
> ^^^^
> This is bool
>
> 32 struct bch_inode_unpacked *inode)
> 33 {
> 34 if (d.v->d_type == DT_SUBVOL
> 35 ? le32_to_cpu(d.v->d_child_subvol) ==
> inode->bi_subvol
> 36 : le64_to_cpu(d.v->d_inum) ==
> inode->bi_inum)
> 37 return 0;
> --> 38 return -BCH_ERR_ENOENT_dirent_doesnt_match_inode;
Thanks! Applied the following:
>From 6bd7310a9b1c19e10b0f116c07c8b6abfd4e165f Mon Sep 17 00:00:00 2001
From: Kent Overstreet <[email protected]>
Date: Tue, 1 Oct 2024 17:43:36 -0400
Subject: [PATCH] bcachefs: Fix return type of dirent_points_to_inode_nowarn()
we're returning an error code now, not a bool
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c
index 0d8b782b63fb..c6c98ee87ec9 100644
--- a/fs/bcachefs/fsck.c
+++ b/fs/bcachefs/fsck.c
@@ -28,8 +28,8 @@ static bool inode_points_to_dirent(struct bch_inode_unpacked
*inode,
inode->bi_dir_offset == d.k->p.offset;
}
-static bool dirent_points_to_inode_nowarn(struct bkey_s_c_dirent d,
- struct bch_inode_unpacked *inode)
+static int dirent_points_to_inode_nowarn(struct bkey_s_c_dirent d,
+ struct bch_inode_unpacked *inode)
{
if (d.v->d_type == DT_SUBVOL
? le32_to_cpu(d.v->d_child_subvol) == inode->bi_subvol