From b5aac254c71dbf92d4cf6ad77ba904350843861e Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 15 Sep 2022 13:59:39 +0200 Subject: [PATCH] btrfs-progs: common: update include lists, part 1 The tool IWYU (include what you use) suggests to remove and add some includes. This is only partial to avoid accidental build breakage, the includes are entangled and will have to be cleaned in the future again. Signed-off-by: David Sterba --- btrfs.c | 4 ++-- check/qgroup-verify.c | 19 ++++++++----------- common/device-scan.c | 4 ++++ common/device-scan.h | 2 -- common/device-utils.c | 7 ++++++- common/extent-cache.c | 1 + common/extent-cache.h | 1 + common/filesystem-utils.c | 3 ++- common/filesystem-utils.h | 2 ++ common/format-output.c | 5 +++++ common/format-output.h | 2 ++ common/fsfeatures.c | 7 +++++++ common/fsfeatures.h | 2 ++ common/help.c | 3 +-- common/help.h | 9 ++++++--- common/open-utils.c | 5 +++++ common/open-utils.h | 1 + common/parse-utils.c | 5 ++++- common/path-utils.c | 2 +- common/rbtree-utils.c | 4 ++++ common/repair.c | 9 ++++++++- common/repair.h | 5 +++++ common/send-stream.c | 9 +++++++-- common/send-utils.c | 4 +++- common/send-utils.h | 2 +- common/string-table.h | 2 ++ common/string-utils.h | 2 ++ common/task-utils.c | 1 - common/task-utils.h | 1 + common/units.c | 2 ++ common/units.h | 1 + common/utils.c | 14 -------------- common/utils.h | 5 +++-- 33 files changed, 99 insertions(+), 46 deletions(-) diff --git a/btrfs.c b/btrfs.c index 4c64f953..a1db7109 100644 --- a/btrfs.c +++ b/btrfs.c @@ -27,6 +27,7 @@ #include "common/string-utils.h" #include "common/help.h" #include "common/box.h" +#include "common/messages.h" #include "cmds/commands.h" static const char * const btrfs_cmd_group_usage[] = { @@ -108,8 +109,7 @@ static void check_output_format(const struct cmd_struct *cmd) return; if (!(cmd->flags & bconf.output_format & CMD_FORMAT_MASK)) { - fprintf(stderr, - "ERROR: output format %s is unsupported for this command\n", + error("output format %s is unsupported for this command", output_format_name(bconf.output_format)); exit(1); } diff --git a/check/qgroup-verify.c b/check/qgroup-verify.c index 39665266..8d49b79a 100644 --- a/check/qgroup-verify.c +++ b/check/qgroup-verify.c @@ -961,7 +961,7 @@ loop: ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) { - fprintf(stderr, "ERROR: Couldn't search slot: %d\n", ret); + error("couldn't search slot: %d", ret); goto out; } @@ -1006,7 +1006,7 @@ loop: count = alloc_count(&disk_key, leaf, item); if (!count) { ret = ENOMEM; - fprintf(stderr, "ERROR: out of memory\n"); + error("out of memory"); goto out; } @@ -1176,7 +1176,7 @@ static int scan_extents(struct btrfs_fs_info *info, ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) { - fprintf(stderr, "ERROR: Couldn't search slot: %d\n", ret); + error("couldn't search slot: %d", ret); goto out; } path.reada = READA_BACK; @@ -1246,8 +1246,7 @@ static int scan_extents(struct btrfs_fs_info *info, ret = btrfs_next_leaf(root, &path); if (ret != 0) { if (ret < 0) { - fprintf(stderr, - "ERROR: Next leaf failed: %d\n", ret); + error("next leaf failed: %d", ret); goto out; } break; @@ -1415,14 +1414,13 @@ int qgroup_verify_all(struct btrfs_fs_info *info) tree_blocks = ulist_alloc(0); if (!tree_blocks) { - fprintf(stderr, - "ERROR: Out of memory while allocating ulist.\n"); + error("out of memory while allocating ulist"); return ENOMEM; } ret = load_quota_info(info); if (ret) { - fprintf(stderr, "ERROR: Loading qgroups from disk: %d\n", ret); + error("loading qgroups from disk: %d", ret); goto out; } @@ -1442,15 +1440,14 @@ int qgroup_verify_all(struct btrfs_fs_info *info) ret = scan_extents(info, bg->start, bg->start + bg->length - 1); if (ret) { - fprintf(stderr, "ERROR: while scanning extent tree: %d\n", - ret); + error("while scanning extent tree: %d", ret); goto out; } } ret = map_implied_refs(info); if (ret) { - fprintf(stderr, "ERROR: while mapping refs: %d\n", ret); + error("while mapping refs: %d", ret); goto out; } diff --git a/common/device-scan.c b/common/device-scan.c index b5a1f85a..660382b2 100644 --- a/common/device-scan.c +++ b/common/device-scan.c @@ -20,6 +20,7 @@ #include "kerncompat.h" #include +#include #include #include #include @@ -28,6 +29,8 @@ #include #include #include +#include +#include #include #include #ifdef HAVE_LIBUDEV @@ -35,6 +38,7 @@ #include #endif #include "kernel-lib/overflow.h" +#include "kernel-lib/list.h" #include "kernel-shared/ctree.h" #include "kernel-shared/volumes.h" #include "kernel-shared/disk-io.h" diff --git a/common/device-scan.h b/common/device-scan.h index ca10fc65..13a16e0a 100644 --- a/common/device-scan.h +++ b/common/device-scan.h @@ -36,8 +36,6 @@ struct btrfs_root; struct btrfs_trans_handle; -struct seen_fsid; -struct DIR; struct seen_fsid { u8 fsid[BTRFS_FSID_SIZE]; diff --git a/common/device-utils.c b/common/device-utils.c index b0fd10ef..d2a65d65 100644 --- a/common/device-utils.c +++ b/common/device-utils.c @@ -15,9 +15,12 @@ */ #include -#include +#include #include #include +#ifdef BTRFS_ZONED +#include +#endif #include #include #include @@ -26,9 +29,11 @@ #include #include #include +#include #include #include "kernel-lib/sizes.h" #include "kernel-shared/disk-io.h" +#include "kernel-shared/ctree.h" #include "kernel-shared/zoned.h" #include "common/device-utils.h" #include "common/path-utils.h" diff --git a/common/extent-cache.c b/common/extent-cache.c index b2b70f4e..4f6d48cd 100644 --- a/common/extent-cache.c +++ b/common/extent-cache.c @@ -19,6 +19,7 @@ #include "kerncompat.h" #include #include +#include #include "common/extent-cache.h" #include "common/rbtree-utils.h" diff --git a/common/extent-cache.h b/common/extent-cache.h index c6614fb2..5df8109b 100644 --- a/common/extent-cache.h +++ b/common/extent-cache.h @@ -21,6 +21,7 @@ #include "kerncompat.h" #include "kernel-lib/rbtree.h" +#include "kernel-lib/rbtree_types.h" struct cache_tree { struct rb_root root; diff --git a/common/filesystem-utils.c b/common/filesystem-utils.c index f92d84af..3bcdec57 100644 --- a/common/filesystem-utils.c +++ b/common/filesystem-utils.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "kernel-shared/ctree.h" #include "kernel-shared/disk-io.h" #include "kernel-shared/transaction.h" @@ -25,7 +27,6 @@ #include "common/messages.h" #include "common/open-utils.h" #include "common/path-utils.h" -#include "ioctl.h" /* * For a given: diff --git a/common/filesystem-utils.h b/common/filesystem-utils.h index a8d42593..c134287f 100644 --- a/common/filesystem-utils.h +++ b/common/filesystem-utils.h @@ -17,6 +17,8 @@ #ifndef __BTRFS_FILESYSTEM_UTILS_H__ #define __BTRFS_FILESYSTEM_UTILS_H__ +#include "kerncompat.h" + int lookup_path_rootid(int fd, u64 *rootid); int get_label(const char *btrfs_dev, char *label); int set_label(const char *btrfs_dev, const char *label); diff --git a/common/format-output.c b/common/format-output.c index 2bc6f8ae..f0ec81fe 100644 --- a/common/format-output.c +++ b/common/format-output.c @@ -16,6 +16,11 @@ #include "kerncompat.h" #include +#include +#include +#include +#include +#include #include #include "common/defs.h" #include "common/format-output.h" diff --git a/common/format-output.h b/common/format-output.h index bcc2d74d..95e2a117 100644 --- a/common/format-output.h +++ b/common/format-output.h @@ -17,6 +17,8 @@ #ifndef __BTRFS_FORMAT_OUTPUT_H__ #define __BTRFS_FORMAT_OUTPUT_H__ +#include + struct rowspec { /* Identifier for the row */ const char *key; diff --git a/common/fsfeatures.c b/common/fsfeatures.c index d9e5bb55..ad66c3d6 100644 --- a/common/fsfeatures.c +++ b/common/fsfeatures.c @@ -19,10 +19,17 @@ #include #include #include +#include +#include +#include +#include +#include "kernel-lib/sizes.h" #include "kernel-shared/ctree.h" #include "common/fsfeatures.h" #include "common/string-utils.h" #include "common/utils.h" +#include "common/messages.h" +#include "ioctl.h" /* * Insert a root item for temporary tree root diff --git a/common/fsfeatures.h b/common/fsfeatures.h index a8d77fd4..fd7defc1 100644 --- a/common/fsfeatures.h +++ b/common/fsfeatures.h @@ -18,6 +18,8 @@ #define __BTRFS_FSFEATURES_H__ #include "kerncompat.h" +#include +#include "kernel-lib/sizes.h" #define BTRFS_MKFS_DEFAULT_NODE_SIZE SZ_16K #define BTRFS_MKFS_DEFAULT_FEATURES \ diff --git a/common/help.c b/common/help.c index 9cbef7f4..f806ff31 100644 --- a/common/help.c +++ b/common/help.c @@ -14,12 +14,11 @@ * Boston, MA 021110-1307, USA. */ +#include "kerncompat.h" #include #include #include -#include #include -#include "common/utils.h" #include "common/help.h" #include "common/string-utils.h" #include "cmds/commands.h" diff --git a/common/help.h b/common/help.h index 448e51c9..f33cfc96 100644 --- a/common/help.h +++ b/common/help.h @@ -17,6 +17,12 @@ #ifndef __BTRFS_HELP_H__ #define __BTRFS_HELP_H__ +#include +#include + +struct cmd_struct; +struct cmd_group; + /* User defined long options first option */ #define GETOPT_VAL_FIRST 256 @@ -68,9 +74,6 @@ #define HELPINFO_INSERT_VERBOSE "-v|--verbose increase output verbosity" #define HELPINFO_INSERT_QUIET "-q|--quiet print only errors" -struct cmd_struct; -struct cmd_group; - /* * Descriptor of output format */ diff --git a/common/open-utils.c b/common/open-utils.c index e59f7fd9..d4fdb2b0 100644 --- a/common/open-utils.c +++ b/common/open-utils.c @@ -21,6 +21,11 @@ #include #include #include +#include +#include +#include +#include +#include "kernel-lib/list.h" #include "kernel-shared/ctree.h" #include "kernel-shared/volumes.h" #include "kernel-shared/disk-io.h" diff --git a/common/open-utils.h b/common/open-utils.h index 0ee14444..3924be36 100644 --- a/common/open-utils.h +++ b/common/open-utils.h @@ -17,6 +17,7 @@ #ifndef __OPEN_UTILS_H__ #define __OPEN_UTILS_H__ +#include #include struct btrfs_fs_devices; diff --git a/common/parse-utils.c b/common/parse-utils.c index 5f5fcb4f..11ef2309 100644 --- a/common/parse-utils.c +++ b/common/parse-utils.c @@ -15,11 +15,14 @@ */ #include "kerncompat.h" -#include #include #include #include #include +#include +#include +#include +#include #include "libbtrfsutil/btrfsutil.h" #include "kernel-shared/volumes.h" #include "common/parse-utils.h" diff --git a/common/path-utils.c b/common/path-utils.c index 2fb3a7da..6d12e2bb 100644 --- a/common/path-utils.c +++ b/common/path-utils.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #include "common/path-utils.h" /* diff --git a/common/rbtree-utils.c b/common/rbtree-utils.c index 64dce4e4..5aa9b433 100644 --- a/common/rbtree-utils.c +++ b/common/rbtree-utils.c @@ -16,6 +16,10 @@ * Boston, MA 021110-1307, USA. */ +#include +#include +#include "kernel-lib/rbtree.h" +#include "kernel-lib/rbtree_types.h" #include "common/rbtree-utils.h" int rb_insert(struct rb_root *root, struct rb_node *node, diff --git a/common/repair.c b/common/repair.c index 859024c3..44f1f5b8 100644 --- a/common/repair.c +++ b/common/repair.c @@ -16,11 +16,18 @@ * Boston, MA 021110-1307, USA. */ +#include +#include +#include +#include +#include +#include "kernel-lib/list.h" +#include "kernel-lib/rbtree.h" #include "kernel-shared/ctree.h" #include "kernel-shared/transaction.h" +#include "kernel-shared/extent_io.h" #include "kernel-shared/disk-io.h" #include "common/extent-cache.h" -#include "common/utils.h" #include "common/repair.h" int repair = 0; diff --git a/common/repair.h b/common/repair.h index 1b19739d..48e7ddb1 100644 --- a/common/repair.h +++ b/common/repair.h @@ -19,7 +19,12 @@ #ifndef __BTRFS_REPAIR_H__ #define __BTRFS_REPAIR_H__ +#include "kerncompat.h" #include "kernel-shared/ctree.h" +#include "common/extent-cache.h" + +struct btrfs_trans_handle; +struct extent_io_tree; extern int repair; /* repair mode */ diff --git a/common/send-stream.c b/common/send-stream.c index cb051c3d..ee1c36ae 100644 --- a/common/send-stream.c +++ b/common/send-stream.c @@ -17,11 +17,16 @@ */ #include -#include +#include +#include +#include +#include +#include "kernel-shared/ctree.h" #include "kernel-shared/send.h" #include "crypto/crc32c.h" #include "common/send-stream.h" -#include "common/utils.h" +#include "common/messages.h" +#include "ioctl.h" struct btrfs_send_attribute { u16 tlv_type; diff --git a/common/send-utils.c b/common/send-utils.c index f17d9ac8..b7c681de 100644 --- a/common/send-utils.c +++ b/common/send-utils.c @@ -21,7 +21,9 @@ #include #include #include -#include +#include +#include +#include #include "kernel-shared/ctree.h" #include "common/send-utils.h" #include "common/messages.h" diff --git a/common/send-utils.h b/common/send-utils.h index 95ffcf0e..7bff81a1 100644 --- a/common/send-utils.h +++ b/common/send-utils.h @@ -20,7 +20,7 @@ #define __BTRFS_SEND_UTILS_H__ #include "kerncompat.h" -#include "kernel-lib/rbtree.h" +#include #include "kernel-shared/ctree.h" enum subvol_search_type { diff --git a/common/string-table.h b/common/string-table.h index 516ea97a..8172f47a 100644 --- a/common/string-table.h +++ b/common/string-table.h @@ -17,6 +17,8 @@ #ifndef __STRING_TABLE_H__ #define __STRING_TABLE_H__ +#include + struct string_table { int ncols; int nrows; diff --git a/common/string-utils.h b/common/string-utils.h index 110d34f3..75a2cdb3 100644 --- a/common/string-utils.h +++ b/common/string-utils.h @@ -17,6 +17,8 @@ #ifndef __BTRFS_STRING_UTILS_H__ #define __BTRFS_STRING_UTILS_H__ +#include "kerncompat.h" + int string_is_numerical(const char *str); int prefixcmp(const char *str, const char *prefix); u64 arg_strtou64(const char *str); diff --git a/common/task-utils.c b/common/task-utils.c index 681b4356..5bcbfb23 100644 --- a/common/task-utils.c +++ b/common/task-utils.c @@ -16,7 +16,6 @@ #include #include -#include #include #include #include diff --git a/common/task-utils.h b/common/task-utils.h index bbb0f1fd..624d0f94 100644 --- a/common/task-utils.h +++ b/common/task-utils.h @@ -18,6 +18,7 @@ #define __TASK_UTILS_H__ #include "kerncompat.h" +#include #include struct periodic_info { diff --git a/common/units.c b/common/units.c index 502e5151..eaeb7e2f 100644 --- a/common/units.c +++ b/common/units.c @@ -14,6 +14,8 @@ * Boston, MA 021110-1307, USA. */ +#include +#include #include "common/units.h" /* diff --git a/common/units.h b/common/units.h index c12d9c72..d93977ff 100644 --- a/common/units.h +++ b/common/units.h @@ -18,6 +18,7 @@ #define __BTRFS_UNITS_H__ #include "kerncompat.h" +#include /* * Output modes of size diff --git a/common/utils.c b/common/utils.c index ae56050e..7edfe13c 100644 --- a/common/utils.c +++ b/common/utils.c @@ -19,13 +19,7 @@ #include "kerncompat.h" #include -#include -#include #include -#include -#include -#include -#include #include #include #include @@ -34,20 +28,12 @@ #include #include #include -#include -#include #include -#include "libbtrfsutil/btrfsutil.h" -#include "kernel-lib/radix-tree.h" #include "kernel-shared/ctree.h" #include "kernel-shared/disk-io.h" #include "kernel-shared/volumes.h" -#include "kernel-shared/transaction.h" -#include "crypto/crc32c.h" #include "common/utils.h" #include "common/path-utils.h" -#include "common/device-scan.h" -#include "common/parse-utils.h" #include "common/open-utils.h" #include "cmds/commands.h" #include "mkfs/common.h" diff --git a/common/utils.h b/common/utils.h index a3118e63..dc76dbdb 100644 --- a/common/utils.h +++ b/common/utils.h @@ -19,9 +19,10 @@ #ifndef __BTRFS_UTILS_H__ #define __BTRFS_UTILS_H__ -#include -#include +#include "kerncompat.h" #include +#include +#include #include "kernel-lib/sizes.h" #include "kernel-shared/ctree.h" #include "common/defs.h"