From: Philipp Hahn Date: Tue, 10 Mar 2026 11:48:28 +0000 (+0100) Subject: btrfs: prefer IS_ERR_OR_NULL() over manual NULL check X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e5267796482fad93ee7948c7cbc37f32046244f7;p=thirdparty%2Fkernel%2Flinux.git btrfs: prefer IS_ERR_OR_NULL() over manual NULL check Prefer using IS_ERR_OR_NULL() over using IS_ERR() and a manual NULL check. IS_ERR_OR_NULL() already uses likely(!ptr) internally. checkpatch does not like nesting it: > WARNING: nested (un)?likely() calls, IS_ERR_OR_NULL already uses > unlikely() internally Remove the explicit use of likely(). Change generated with coccinelle. Signed-off-by: Philipp Hahn Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c1abeb72069ca..8d97a8ad3858b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4691,7 +4691,7 @@ static noinline int may_destroy_subvol(struct btrfs_root *root) dir_id = btrfs_super_root_dir(fs_info->super_copy); di = btrfs_lookup_dir_item(NULL, fs_info->tree_root, path, dir_id, &name, 0); - if (di && !IS_ERR(di)) { + if (!IS_ERR_OR_NULL(di)) { btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key); if (key.objectid == btrfs_root_id(root)) { ret = -EPERM; diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 79c488f120b23..4358f4b630572 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1754,7 +1754,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, dir_item = btrfs_lookup_dir_item(NULL, parent_root, path, btrfs_ino(parent_inode), &fname.disk_name, 0); - if (unlikely(dir_item != NULL && !IS_ERR(dir_item))) { + if (!IS_ERR_OR_NULL(dir_item)) { pending->error = -EEXIST; goto dir_item_existed; } else if (IS_ERR(dir_item)) { diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index af8de67d1304b..a87fdfd465b31 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -5801,7 +5801,7 @@ static int btrfs_check_ref_name_override(struct extent_buffer *eb, name_str.len = this_name_len; di = btrfs_lookup_dir_item(NULL, inode->root, search_path, parent, &name_str, 0); - if (di && !IS_ERR(di)) { + if (!IS_ERR_OR_NULL(di)) { struct btrfs_key di_key; btrfs_dir_item_key_to_cpu(search_path->nodes[0], diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c index 276f0eb874d4f..467dff7212d69 100644 --- a/fs/btrfs/uuid-tree.c +++ b/fs/btrfs/uuid-tree.c @@ -513,7 +513,7 @@ skip: out: btrfs_free_path(path); - if (trans && !IS_ERR(trans)) + if (!IS_ERR_OR_NULL(trans)) btrfs_end_transaction(trans); if (ret) btrfs_warn(fs_info, "btrfs_uuid_scan_kthread failed %d", ret);