summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-09-20 01:32:20 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:14 -0400
commit40a53b92150fe9576538f775138413c40cdb30cf (patch)
treee1cb18facfe52e36dfa93ffd5485a29a73967c0a
parent51c801bc6414e88d686fb3229c54d7dda1508778 (diff)
downloadlwn-40a53b92150fe9576538f775138413c40cdb30cf.tar.gz
lwn-40a53b92150fe9576538f775138413c40cdb30cf.zip
bcachefs: More minor smatch fixes
- fix a few uninitialized return values - return a proper error code in lookup_lostfound() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/btree_update.c2
-rw-r--r--fs/bcachefs/errcode.h1
-rw-r--r--fs/bcachefs/fsck.c2
-rw-r--r--fs/bcachefs/io_write.c2
-rw-r--r--fs/bcachefs/move.c2
-rw-r--r--fs/bcachefs/super-io.c2
6 files changed, 6 insertions, 5 deletions
diff --git a/fs/bcachefs/btree_update.c b/fs/bcachefs/btree_update.c
index 3342718de45d..324767c0ddcc 100644
--- a/fs/bcachefs/btree_update.c
+++ b/fs/bcachefs/btree_update.c
@@ -124,7 +124,7 @@ int __bch2_insert_snapshot_whiteouts(struct btree_trans *trans,
struct bkey_s_c old_k, new_k;
snapshot_id_list s;
struct bkey_i *update;
- int ret;
+ int ret = 0;
if (!bch2_snapshot_has_children(c, old_pos.snapshot))
return 0;
diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h
index 56b6ce278648..64f7176c2a4e 100644
--- a/fs/bcachefs/errcode.h
+++ b/fs/bcachefs/errcode.h
@@ -99,6 +99,7 @@
x(ENOENT, ENOENT_str_hash_set_must_replace) \
x(ENOENT, ENOENT_inode) \
x(ENOENT, ENOENT_not_subvol) \
+ x(ENOENT, ENOENT_not_directory) \
x(ENOENT, ENOENT_directory_dead) \
x(ENOENT, ENOENT_subvolume) \
x(ENOENT, ENOENT_snapshot_tree) \
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c
index e3d68082fdd3..206302b0f5ed 100644
--- a/fs/bcachefs/fsck.c
+++ b/fs/bcachefs/fsck.c
@@ -281,7 +281,7 @@ static int lookup_lostfound(struct btree_trans *trans, u32 subvol,
if (d_type != DT_DIR) {
bch_err(c, "error looking up lost+found: not a directory");
- return ret;
+ return -BCH_ERR_ENOENT_not_directory;
}
/*
diff --git a/fs/bcachefs/io_write.c b/fs/bcachefs/io_write.c
index 659330cbe357..d2a0de886c7a 100644
--- a/fs/bcachefs/io_write.c
+++ b/fs/bcachefs/io_write.c
@@ -930,7 +930,7 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
do {
struct bch_extent_crc_unpacked crc = { 0 };
struct bversion version = op->version;
- size_t dst_len, src_len;
+ size_t dst_len = 0, src_len = 0;
if (page_alloc_failed &&
dst->bi_iter.bi_size < (wp->sectors_free << 9) &&
diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c
index c1aa76f9f845..39a14e321680 100644
--- a/fs/bcachefs/move.c
+++ b/fs/bcachefs/move.c
@@ -627,7 +627,7 @@ int bch2_move_data(struct bch_fs *c,
{
struct moving_context ctxt;
enum btree_id id;
- int ret;
+ int ret = 0;
bch2_moving_ctxt_init(&ctxt, c, rate, stats, wp, wait_on_copygc);
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index e0bd50983bb2..55bc03d2e8ed 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -185,7 +185,7 @@ int bch2_sb_realloc(struct bch_sb_handle *sb, unsigned u64s)
if (sb->sb && sb->buffer_size >= new_buffer_size)
return 0;
- if (sb->have_layout) {
+ if (sb->sb && sb->have_layout) {
u64 max_bytes = 512 << sb->sb->layout.sb_max_size_bits;
if (new_bytes > max_bytes) {