Misc warning fixes
David Sterba
maintainercover Misc warning fixes
Compiling with W=1 or W=2 gives warnings that seem to be worth fixing.
David Sterba (5):
btrfs: remove const from btrfs_feature_set_name
btrfs: compression: move declarations to header
btrfs: remove unnecessarily shadowed variables
btrfs: scrub: rename ratelimit state varaible to avoid shadowing
btrfs: send: remove indirect callback parameter for changed_cb
fs/btrfs/backref.c | 1 - fs/btrfs/compression.c | 35 ----------------------------------- fs/btrfs/compression.h | 35 +++++++++++++++++++++++++++++++++++ fs/btrfs/inode.c | 1 - fs/btrfs/scrub.c | 8 ++++---- fs/btrfs/send.c | 11 ++--------- fs/btrfs/sysfs.c | 2 +- fs/btrfs/sysfs.h | 2 +- 8 files changed, 43 insertions(+), 52 deletions(-)
Signature · 1 line
2.25.0
David Sterba
maintainerPATCH 1/5 btrfs: remove const from btrfs_feature_set_name
The function btrfs_feature_set_name returns a const char pointer, the second const is not necessary and reported as a warning:
In file included from fs/btrfs/space-info.c:6:
fs/btrfs/sysfs.h:16:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
16 | const char * const btrfs_feature_set_name(enum btrfs_feature_set set);
| ^~~~~--- fs/btrfs/sysfs.c | 2 +- fs/btrfs/sysfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/sysfs.c +1 -1
@@ -973,7 +973,7 @@ static const char * const btrfs_feature_set_names[FEAT_MAX] = { [FEAT_INCOMPAT] = "incompat", }; -const char *const btrfs_feature_set_name (enum btrfs_feature_set set) +const char *btrfs_feature_set_name (enum btrfs_feature_set set) {return btrfs_feature_set_names[set]; }
fs/btrfs/sysfs.h +1 -1
@@ -13,7 +13,7 @@ enum btrfs_feature_set { };char *btrfs_printable_features (enum btrfs_feature_set set,u64 flags); -const char *const btrfs_feature_set_name (enum btrfs_feature_set set); +const char *btrfs_feature_set_name (enum btrfs_feature_set set);int btrfs_sysfs_add_devices_dir (struct btrfs_fs_devices *fs_devices,struct btrfs_device *one_device); int btrfs_sysfs_remove_devices_dir(struct btrfs_fs_devices *fs_devices,
Signature · 1 line
2.25.0
David Sterba
maintainerPATCH 2/5 btrfs: compression: move declarations to header
In reply to David SterbaThe declarations of compression algorithm callbacks are defined in the .c file as they're used from there. Compiler warns that there are no declarations for public functions when compiling lzo.c/zlib.c/zstd.c. Fix that by moving the declarations to the header as it's the common place for all of them.
--- fs/btrfs/compression.c | 35 ----------------------------------- fs/btrfs/compression.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 35 deletions(-)
fs/btrfs/compression.c +0 -35
@@ -29,41 +29,6 @@#include "extent_io.h" #include "extent_map.h" -int zlib_compress_pages (struct list_head *ws,struct address_space *mapping, -u64 start,struct page **pages,unsigned long *out_pages, -unsigned long *total_in,unsigned long *total_out); -int zlib_decompress_bio (struct list_head *ws,struct compressed_bio *cb); -int zlib_decompress (struct list_head *ws,unsigned char *data_in, -struct page *dest_page,unsigned long start_byte,size_t srclen, -size_t destlen); -struct list_head *zlib_alloc_workspace (unsigned int level); -void zlib_free_workspace (struct list_head *ws); -struct list_head *zlib_get_workspace (unsigned int level); - -int lzo_compress_pages (struct list_head *ws,struct address_space *mapping, -u64 start,struct page **pages,unsigned long *out_pages, -unsigned long *total_in,unsigned long *total_out); -int lzo_decompress_bio (struct list_head *ws,struct compressed_bio *cb); -int lzo_decompress (struct list_head *ws,unsigned char *data_in, -struct page *dest_page,unsigned long start_byte,size_t srclen, -size_t destlen); -struct list_head *lzo_alloc_workspace (unsigned int level); -void lzo_free_workspace (struct list_head *ws); - -int zstd_compress_pages (struct list_head *ws,struct address_space *mapping, -u64 start,struct page **pages,unsigned long *out_pages, -unsigned long *total_in,unsigned long *total_out); -int zstd_decompress_bio (struct list_head *ws,struct compressed_bio *cb); -int zstd_decompress (struct list_head *ws,unsigned char *data_in, -struct page *dest_page,unsigned long start_byte,size_t srclen, -size_t destlen); -void zstd_init_workspace_manager (void ); -void zstd_cleanup_workspace_manager (void ); -struct list_head *zstd_alloc_workspace (unsigned int level); -void zstd_free_workspace (struct list_head *ws); -struct list_head *zstd_get_workspace (unsigned int level); -void zstd_put_workspace (struct list_head *ws); -static const char *const btrfs_compress_types[] = {"" ,"zlib" ,"lzo" ,"zstd" };const char *btrfs_compress_type2str (enum btrfs_compression_type type)
fs/btrfs/compression.h +35 -0
@@ -144,4 +144,39 @@ bool btrfs_compress_is_valid_type(const char *str, size_t len);int btrfs_compress_heuristic (struct inode *inode,u64 start,u64 end); +int zlib_compress_pages (struct list_head *ws,struct address_space *mapping, +u64 start,struct page **pages,unsigned long *out_pages, +unsigned long *total_in,unsigned long *total_out); +int zlib_decompress_bio (struct list_head *ws,struct compressed_bio *cb); +int zlib_decompress (struct list_head *ws,unsigned char *data_in, +struct page *dest_page,unsigned long start_byte,size_t srclen, +size_t destlen); +struct list_head *zlib_alloc_workspace (unsigned int level); +void zlib_free_workspace (struct list_head *ws); +struct list_head *zlib_get_workspace (unsigned int level); + +int lzo_compress_pages (struct list_head *ws,struct address_space *mapping, +u64 start,struct page **pages,unsigned long *out_pages, +unsigned long *total_in,unsigned long *total_out); +int lzo_decompress_bio (struct list_head *ws,struct compressed_bio *cb); +int lzo_decompress (struct list_head *ws,unsigned char *data_in, +struct page *dest_page,unsigned long start_byte,size_t srclen, +size_t destlen); +struct list_head *lzo_alloc_workspace (unsigned int level); +void lzo_free_workspace (struct list_head *ws); + +int zstd_compress_pages (struct list_head *ws,struct address_space *mapping, +u64 start,struct page **pages,unsigned long *out_pages, +unsigned long *total_in,unsigned long *total_out); +int zstd_decompress_bio (struct list_head *ws,struct compressed_bio *cb); +int zstd_decompress (struct list_head *ws,unsigned char *data_in, +struct page *dest_page,unsigned long start_byte,size_t srclen, +size_t destlen); +void zstd_init_workspace_manager (void ); +void zstd_cleanup_workspace_manager (void ); +struct list_head *zstd_alloc_workspace (unsigned int level); +void zstd_free_workspace (struct list_head *ws); +struct list_head *zstd_get_workspace (unsigned int level); +void zstd_put_workspace (struct list_head *ws); +#endif
Signature · 1 line
2.25.0
David Sterba
maintainerPATCH 3/5 btrfs: remove unnecessarily shadowed variables
In reply to David SterbaIn btrfs_orphan_cleanup, there's another instance of fs_info, but it's the same as the one we already have.
In btrfs_backref_finish_upper_links, rb_node is same type and used as temporary cursor to the tree.
--- fs/btrfs/backref.c | 1 - fs/btrfs/inode.c | 1 - 2 files changed, 2 deletions(-)
fs/btrfs/backref.c +0 -1
@@ -2997,7 +2997,6 @@ int btrfs_backref_finish_upper_links(struct btrfs_backref_cache *cache,while (!list_empty (&pending_edge)) {struct btrfs_backref_node *upper;struct btrfs_backref_node *lower; -struct rb_node *rb_node; edge =list_first_entry (&pending_edge, struct btrfs_backref_edge, list[UPPER]);
fs/btrfs/inode.c +0 -1
@@ -3055,7 +3055,6 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)if (ret == -ENOENT && root == fs_info->tree_root) {struct btrfs_root *dead_root; -struct btrfs_fs_info *fs_info = root->fs_info;int is_dead_root =0 ;/*
Signature · 1 line
2.25.0
David Sterba
maintainerPATCH 4/5 btrfs: scrub: rename ratelimit state varaible to avoid shadowing
In reply to David SterbaThere's already defined _rs within ctree.h:btrfs_printk_ratelimited, local variables should not use _ to avoid such name clashes with macro-local variables.
--- fs/btrfs/scrub.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/scrub.c +4 -4
@@ -835,7 +835,7 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)int success;bool full_stripe_locked;unsigned int nofs_flag; - static DEFINE_RATELIMIT_STATE(_rs, DEFAULT_RATELIMIT_INTERVAL, + static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);BUG_ON (sblock_to_check->page_count <1 );
@@ -969,14 +969,14 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)spin_lock (&sctx->stat_lock); sctx->stat.read_errors++;spin_unlock (&sctx->stat_lock); -if (__ratelimit (&_rs)) +if (__ratelimit (&rs))scrub_print_warning ("i/o error" , sblock_to_check);btrfs_dev_stat_inc_and_print (dev,BTRFS_DEV_STAT_READ_ERRS ); }else if (sblock_bad->checksum_error) {spin_lock (&sctx->stat_lock); sctx->stat.csum_errors++;spin_unlock (&sctx->stat_lock); -if (__ratelimit (&_rs)) +if (__ratelimit (&rs))scrub_print_warning ("checksum error" , sblock_to_check);btrfs_dev_stat_inc_and_print (dev,BTRFS_DEV_STAT_CORRUPTION_ERRS );
@@ -984,7 +984,7 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)spin_lock (&sctx->stat_lock); sctx->stat.verify_errors++;spin_unlock (&sctx->stat_lock); -if (__ratelimit (&_rs)) +if (__ratelimit (&rs))scrub_print_warning ("checksum/header error" , sblock_to_check);if (sblock_bad->generation_error)
Signature · 1 line
2.25.0
David Sterba
maintainerPATCH 5/5 btrfs: send: remove indirect callback parameter for changed_cb
In reply to David SterbaThere's a custom callback passed to btrfs_compare_trees which happens to be named exactly same as the existing function implementing it. This is confusing and the indirection is not necessary for our needs. Compiler is clever enough to call it directly so there's effectively no change.
--- fs/btrfs/send.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
fs/btrfs/send.c +2 -9
@@ -278,11 +278,6 @@ enum btrfs_compare_tree_result {BTRFS_COMPARE_TREE_CHANGED , BTRFS_COMPARE_TREE_SAME, }; -typedef int (*btrfs_changed_cb_t )(struct btrfs_path *left_path, -struct btrfs_path *right_path, -struct btrfs_key *key, -enum btrfs_compare_tree_result result, -void *ctx);__cold static void inconsistent_snapshot_error(struct send_ctx *sctx,
@@ -6692,8 +6687,7 @@ static int tree_compare_item(struct btrfs_path *left_path,* If it detects a change, it aborts immediately. */ static int btrfs_compare_trees (struct btrfs_root *left_root, -struct btrfs_root *right_root, -btrfs_changed_cb_t changed_cb,void *ctx) +struct btrfs_root *right_root,void *ctx) {struct btrfs_fs_info *fs_info = left_root->fs_info;int ret;
@@ -6960,8 +6954,7 @@ static int send_subvol(struct send_ctx *sctx) goto out;if (sctx->parent_root) { - ret =btrfs_compare_trees (sctx->send_root, sctx->parent_root, - changed_cb, sctx); + ret =btrfs_compare_trees (sctx->send_root, sctx->parent_root, sctx);if (ret <0 ) goto out; ret =finish_inode_if_needed (sctx,1 );
Signature · 1 line
2.25.0
Quoted 9 lines · David Sterba
Compiling with W=1 or W=2 gives warnings that seem to be worth fixing.
David Sterba (5):
btrfs: remove const frombtrfs_feature_set_name
btrfs: compression: move declarations to header
btrfs: remove unnecessarily shadowed variables
btrfs: scrub: rename ratelimit state varaible to avoid shadowing
btrfs: send: remove indirect callback parameter forchanged_cb
Quoted 10 lines
fs/btrfs/backref.c | 1 - fs/btrfs/compression.c | 35 ----------------------------------- fs/btrfs/compression.h | 35 +++++++++++++++++++++++++++++++++++ fs/btrfs/inode.c | 1 - fs/btrfs/scrub.c | 8 ++++---- fs/btrfs/send.c | 11 ++--------- fs/btrfs/sysfs.c | 2 +- fs/btrfs/sysfs.h | 2 +- 8 files changed, 43 insertions(+), 52 deletions(-)
The whole series can have
Thanks,
Josef