bcachefs: More minor smatch fixes
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 20 Sep 2023 05:32:20 +0000 (01:32 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:14 +0000 (17:10 -0400)
 - fix a few uninitialized return values
 - return a proper error code in lookup_lostfound()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_update.c
fs/bcachefs/errcode.h
fs/bcachefs/fsck.c
fs/bcachefs/io_write.c
fs/bcachefs/move.c
fs/bcachefs/super-io.c

index 3342718de45d700a579ddec5ad7b5c2e36cd4421..324767c0ddccd7457004a34e8ed6e49da8c54b85 100644 (file)
@@ -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;
index 56b6ce278648b2a7e0f7fc1ae92076cee1715ddc..64f7176c2a4e69fdd6bdf30ecc6b4a376f838680 100644 (file)
@@ -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)                   \
index e3d68082fdd36216c710529729667563566fbc3e..206302b0f5ed8a6393b7a9f97fc6b1d0d89bb0d4 100644 (file)
@@ -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;
        }
 
        /*
index 659330cbe357d2e89061446a92aae100e6fcdf65..d2a0de886c7a48b47577975d4e3fd5d0647acf8f 100644 (file)
@@ -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) &&
index c1aa76f9f845a2684fdad91047687ff0e960bb25..39a14e3216807d222fc11856fa285448f4a24ca3 100644 (file)
@@ -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);
 
index e0bd50983bb2c31f277dfe1664f8078cd2d02e22..55bc03d2e8ed56113011cc529aca6a6f1c8a16a3 100644 (file)
@@ -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) {