]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: pass literal booleans to functions that take boolean arguments
authorFilipe Manana <fdmanana@suse.com>
Tue, 10 Feb 2026 12:18:50 +0000 (12:18 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:55:56 +0000 (18:55 +0200)
We have several functions with parameters defined as booleans but then we
have callers passing integers, 0 or 1, instead of false and true. While
this isn't a bug since 0 and 1 are converted to false and true, it is odd
and less readable. Change the callers to pass true and false literals
instead.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c
fs/btrfs/dev-replace.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/qgroup.c
fs/btrfs/reflink.c
fs/btrfs/send.c
fs/btrfs/transaction.c
fs/btrfs/tree-log.c

index f2c925e90a878dff70d5b1bc1b296238aa86410d..b9004345cf3caff73cbc9c54435650ad2bad2854 100644 (file)
@@ -3887,7 +3887,7 @@ static noinline int setup_leaf_for_split(struct btrfs_trans_handle *trans,
                        goto err;
        }
 
-       ret = split_leaf(trans, root, &key, path, ins_len, 1);
+       ret = split_leaf(trans, root, &key, path, ins_len, true);
        if (ret)
                goto err;
 
index b6c7da8e1bc8b1422447df00db9c002a6f323dc3..8f8fa14886dedeb14011fcc8c141e9e6f51b5278 100644 (file)
@@ -697,7 +697,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
        /* the disk copy procedure reuses the scrub code */
        ret = btrfs_scrub_dev(fs_info, src_device->devid, 0,
                              btrfs_device_get_total_bytes(src_device),
-                             &dev_replace->scrub_progress, 0, 1);
+                             &dev_replace->scrub_progress, false, true);
 
        ret = btrfs_dev_replace_finishing(fs_info, ret);
        if (ret == -EINPROGRESS)
@@ -1255,7 +1255,7 @@ static int btrfs_dev_replace_kthread(void *data)
        ret = btrfs_scrub_dev(fs_info, dev_replace->srcdev->devid,
                              dev_replace->committed_cursor_left,
                              btrfs_device_get_total_bytes(dev_replace->srcdev),
-                             &dev_replace->scrub_progress, 0, 1);
+                             &dev_replace->scrub_progress, false, true);
        ret = btrfs_dev_replace_finishing(fs_info, ret);
        WARN_ON(ret && ret != -ECANCELED);
 
index a4cb9d3cfc4e8a909642f3ce17d666b59b62ef83..06cc6e13cb621f2a6d5b8012ef6ca6d9feb0294f 100644 (file)
@@ -3316,8 +3316,8 @@ static bool find_delalloc_subrange(struct btrfs_inode *inode, u64 start, u64 end
                        *delalloc_start_ret = start;
                        delalloc_len = btrfs_count_range_bits(&inode->io_tree,
                                                              delalloc_start_ret, end,
-                                                             len, EXTENT_DELALLOC, 1,
-                                                             cached_state);
+                                                             len, EXTENT_DELALLOC,
+                                                             true, cached_state);
                } else {
                        spin_unlock(&inode->lock);
                }
index 47318fce7a9edd8aa4cc1d860c161126f21972c4..8c2e4472332f5fe5d592c1ca6d3fafa62919272b 100644 (file)
@@ -1854,7 +1854,7 @@ static int fallback_to_cow(struct btrfs_inode *inode,
         */
        btrfs_lock_extent(io_tree, start, end, &cached_state);
        count = btrfs_count_range_bits(io_tree, &range_start, end, range_bytes,
-                                      EXTENT_NORESERVE, 0, NULL);
+                                      EXTENT_NORESERVE, false, NULL);
        if (count > 0 || is_space_ino || is_reloc_ino) {
                u64 bytes = count;
                struct btrfs_fs_info *fs_info = inode->root->fs_info;
@@ -6862,7 +6862,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
                }
        } else {
                ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name,
-                                    0, BTRFS_I(inode)->dir_index);
+                                    false, BTRFS_I(inode)->dir_index);
                if (unlikely(ret)) {
                        btrfs_abort_transaction(trans, ret);
                        goto discard;
@@ -7078,7 +7078,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
        inode_set_ctime_current(inode);
 
        ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
-                            &fname.disk_name, 1, index);
+                            &fname.disk_name, true, index);
        if (ret)
                goto fail;
 
@@ -8498,14 +8498,14 @@ static int btrfs_rename_exchange(struct inode *old_dir,
        }
 
        ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
-                            new_name, 0, old_idx);
+                            new_name, false, old_idx);
        if (unlikely(ret)) {
                btrfs_abort_transaction(trans, ret);
                goto out_fail;
        }
 
        ret = btrfs_add_link(trans, BTRFS_I(old_dir), BTRFS_I(new_inode),
-                            old_name, 0, new_idx);
+                            old_name, false, new_idx);
        if (unlikely(ret)) {
                btrfs_abort_transaction(trans, ret);
                goto out_fail;
@@ -8796,7 +8796,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
        }
 
        ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
-                            &new_fname.disk_name, 0, index);
+                            &new_fname.disk_name, false, index);
        if (unlikely(ret)) {
                btrfs_abort_transaction(trans, ret);
                goto out_fail;
index d75d31b606e499122a4c44db161d0f3ac8e43e71..f2503668ce9deaefd8ecf4a02bda0c65d0f419be 100644 (file)
@@ -3038,7 +3038,7 @@ static long btrfs_ioctl_scrub(struct file *file, void __user *arg)
 
        ret = btrfs_scrub_dev(fs_info, sa->devid, sa->start, sa->end,
                              &sa->progress, sa->flags & BTRFS_SCRUB_READONLY,
-                             0);
+                             false);
 
        /*
         * Copy scrub args to user space even if btrfs_scrub_dev() returned an
index b3107b2278c7496dc9be288f37430a70f1c17ab8..65ec458595071895ece96d3e585fb157ab5669d4 100644 (file)
@@ -2740,8 +2740,6 @@ static void qgroup_iterator_nested_clean(struct list_head *head)
        }
 }
 
-#define UPDATE_NEW     0
-#define UPDATE_OLD     1
 /*
  * Walk all of the roots that points to the bytenr and adjust their refcnts.
  */
@@ -2980,10 +2978,10 @@ int btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, u64 bytenr,
        seq = fs_info->qgroup_seq;
 
        /* Update old refcnts using old_roots */
-       qgroup_update_refcnt(fs_info, old_roots, &qgroups, seq, UPDATE_OLD);
+       qgroup_update_refcnt(fs_info, old_roots, &qgroups, seq, true);
 
        /* Update new refcnts using new_roots */
-       qgroup_update_refcnt(fs_info, new_roots, &qgroups, seq, UPDATE_NEW);
+       qgroup_update_refcnt(fs_info, new_roots, &qgroups, seq, false);
 
        qgroup_update_counters(fs_info, &qgroups, nr_old_roots, nr_new_roots,
                               num_bytes, seq);
index 314cb95ba846d2ff46fc5fcf9ec7b2639e908683..fca00c0f53874fa4af81f27e8c60fc8e6b6ab144 100644 (file)
@@ -646,7 +646,7 @@ static int btrfs_extent_same_range(struct btrfs_inode *src, u64 loff, u64 len,
         */
        btrfs_lock_extent(&dst->io_tree, dst_loff, end, &cached_state);
        ret = btrfs_clone(&src->vfs_inode, &dst->vfs_inode, loff, len,
-                         ALIGN(len, bs), dst_loff, 1);
+                         ALIGN(len, bs), dst_loff, true);
        btrfs_unlock_extent(&dst->io_tree, dst_loff, end, &cached_state);
 
        btrfs_btree_balance_dirty(fs_info);
@@ -747,7 +747,7 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
         */
        end = destoff + len - 1;
        btrfs_lock_extent(&BTRFS_I(inode)->io_tree, destoff, end, &cached_state);
-       ret = btrfs_clone(src, inode, off, olen, len, destoff, 0);
+       ret = btrfs_clone(src, inode, off, olen, len, destoff, false);
        btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, destoff, end, &cached_state);
        if (ret < 0)
                return ret;
index 904a2f57f86dc4cd90062836f4f797bdfe25baed..89d72d8cb85fdf3103c79b476ad1cea82c73910d 100644 (file)
@@ -7201,7 +7201,7 @@ static int changed_cb(struct btrfs_path *left_path,
        sctx->right_path = right_path;
        sctx->cmp_key = key;
 
-       ret = finish_inode_if_needed(sctx, 0);
+       ret = finish_inode_if_needed(sctx, false);
        if (ret < 0)
                return ret;
 
@@ -7328,7 +7328,7 @@ static int full_send_tree(struct send_ctx *sctx)
        }
 
 out_finish:
-       return finish_inode_if_needed(sctx, 1);
+       return finish_inode_if_needed(sctx, true);
 }
 
 static int replace_node_with_clone(struct btrfs_path *path, int level)
@@ -7879,7 +7879,7 @@ static int send_subvol(struct send_ctx *sctx)
                ret = btrfs_compare_trees(sctx->send_root, sctx->parent_root, sctx);
                if (ret < 0)
                        goto out;
-               ret = finish_inode_if_needed(sctx, 1);
+               ret = finish_inode_if_needed(sctx, true);
                if (ret < 0)
                        goto out;
        } else {
index 2df80452b0b74031baa1e7d495076d4c6c4e0bca..ca780e332a5bfe220a4ff85c581faf422bbac30f 100644 (file)
@@ -503,7 +503,7 @@ int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,
                return 0;
 
        mutex_lock(&fs_info->reloc_mutex);
-       ret = record_root_in_trans(trans, root, 0);
+       ret = record_root_in_trans(trans, root, false);
        mutex_unlock(&fs_info->reloc_mutex);
 
        return ret;
@@ -1579,7 +1579,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
         * recorded root will never be updated again, causing an outdated root
         * item.
         */
-       ret = record_root_in_trans(trans, src, 1);
+       ret = record_root_in_trans(trans, src, true);
        if (ret)
                return ret;
 
@@ -1642,7 +1642,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
         * Or it won't be committed again onto disk after later
         * insert_dir_item()
         */
-       return record_root_in_trans(trans, parent, 1);
+       return record_root_in_trans(trans, parent, true);
 }
 
 /*
@@ -1726,7 +1726,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
                                      trans->transid,
                                      trans->bytes_reserved, 1);
        parent_root = parent_inode->root;
-       ret = record_root_in_trans(trans, parent_root, 0);
+       ret = record_root_in_trans(trans, parent_root, false);
        if (unlikely(ret))
                goto fail;
        cur_time = current_time(&parent_inode->vfs_inode);
@@ -1774,7 +1774,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
                goto fail;
        }
 
-       ret = record_root_in_trans(trans, root, 0);
+       ret = record_root_in_trans(trans, root, false);
        if (unlikely(ret)) {
                btrfs_abort_transaction(trans, ret);
                goto fail;
index 340f572c357d04f2d2992922173f63b7ecf639a2..187e07a277bfcfd6ecc35b1464dda40c92869a47 100644 (file)
@@ -1711,7 +1711,7 @@ static noinline int add_inode_ref(struct walk_control *wc)
                        }
 
                        /* insert our name */
-                       ret = btrfs_add_link(trans, dir, inode, &name, 0, ref_index);
+                       ret = btrfs_add_link(trans, dir, inode, &name, false, ref_index);
                        if (ret) {
                                btrfs_abort_log_replay(wc, ret,
 "failed to add link for inode %llu in dir %llu ref_index %llu name %.*s root %llu",
@@ -2059,7 +2059,7 @@ static noinline int insert_one_name(struct btrfs_trans_handle *trans,
                return PTR_ERR(dir);
        }
 
-       ret = btrfs_add_link(trans, dir, inode, name, 1, index);
+       ret = btrfs_add_link(trans, dir, inode, name, true, index);
 
        /* FIXME, put inode into FIXUP list */