Fixes to GCC warnings while compiling with W=1 level
cover Fixes to GCC warnings while compiling with W=1 level
From: Leon Romanovsky <[email protected]>
Hi,
The series of trivial fixes for GCC warnings seen while compiling with W=1.
Thanks
Leon Romanovsky (3):
fs/btfrs: Fix -Wunused-but-set-variable warnings fs/btrfs: Fix -Wignored-qualifiers warnings fs/btrfs: Fix -Wmissing-prototypes warnings
fs/btrfs/compression.c | 35 ----------------------------------- fs/btrfs/compression.h | 35 +++++++++++++++++++++++++++++++++++ fs/btrfs/ctree.c | 2 +- fs/btrfs/ctree.h | 2 +- fs/btrfs/sysfs.c | 7 +++---- fs/btrfs/sysfs.h | 2 +- 6 files changed, 41 insertions(+), 42 deletions(-)
--
2.26.2
PATCH 1/3 fs/btfrs: Fix -Wunused-but-set-variable warnings
From: Leon Romanovsky <[email protected]>
The compilation with W=1 generates the following warnings:
fs/btrfs/sysfs.c:1630:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
1630 | int ret;
| ^~~
fs/btrfs/sysfs.c:1629:6: warning: variable 'features' set but not used [-Wunused-but-set-variable]
1629 | u64 features;
| ^~~~~~~~--- fs/btrfs/sysfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +2 -3
@@ -1626,13 +1626,12 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, {struct btrfs_fs_devices *fs_devs;struct kobject *fsid_kobj; -u64 features; -int ret; +int __maybe_unused ret;if (!fs_info)return ; - features =get_features (fs_info, set); +get_features (fs_info, set);ASSERT (bit & supported_feature_masks[set]); fs_devs = fs_info->fs_devices;
--
2.26.2
PATCH 2/3 fs/btrfs: Fix -Wignored-qualifiers warnings
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
Change function declarations to avoid the following GCC warnings while compiling with W=1 level.
In file included from fs/btrfs/volumes.c:28:
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);
| ^~~~~
In file included from fs/btrfs/ioctl.c:29:
fs/btrfs/ctree.h:2265:8: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
2265 | size_t __const btrfs_get_num_csums(void);
| ^~~~~~~--- fs/btrfs/ctree.c | 2 +- fs/btrfs/ctree.h | 2 +- fs/btrfs/sysfs.c | 2 +- fs/btrfs/sysfs.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/ctree.c +1 -1
@@ -68,7 +68,7 @@ const char *btrfs_super_csum_driver(u16 csum_type) btrfs_csums[csum_type].name; } -size_t __const btrfs_get_num_csums(void) +__attribute_const__ size_t btrfs_get_num_csums(void) {return ARRAY_SIZE (btrfs_csums); }
fs/btrfs/ctree.h +1 -1
@@ -2262,7 +2262,7 @@ BTRFS_SETGET_STACK_FUNCS(super_uuid_tree_generation, struct btrfs_super_block,int btrfs_super_csum_size (const struct btrfs_super_block *s);const char *btrfs_super_csum_name (u16 csum_type);const char *btrfs_super_csum_driver (u16 csum_type); -size_t __const btrfs_get_num_csums(void); +__attribute_const__ size_t btrfs_get_num_csums(void);/*
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,
--
2.26.2
PATCH 3/3 fs/btrfs: Fix -Wmissing-prototypes warnings
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
Move function declaration to shared header file to fix multiple -Wmissing-prototypes warnings like below:
fs/btrfs/zstd.c:369:5: warning: no previous prototype for ‘zstd_compress_pages’ [-Wmissing-prototypes]
369 | int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
| ^~~~~~~~~~~~~~~~~~~
--- 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
--
2.26.2
Quoted 10 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Hi,
The series of trivial fixes for GCC warnings seen while compiling with W=1.
Thanks
Leon Romanovsky (3):
fs/btfrs: Fix -Wunused-but-set-variable warnings
^^^ this is typo - btrfs
Quoted 14 lines
fs/btrfs: Fix -Wignored-qualifiers warnings
fs/btrfs: Fix -Wmissing-prototypes warningsfs/btrfs/compression.c | 35 ----------------------------------- fs/btrfs/compression.h | 35 +++++++++++++++++++++++++++++++++++ fs/btrfs/ctree.c | 2 +- fs/btrfs/ctree.h | 2 +- fs/btrfs/sysfs.c | 7 +++---- fs/btrfs/sysfs.h | 2 +- 6 files changed, 41 insertions(+), 42 deletions(-)--
2.26.2
Quoted 7 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
The series of trivial fixes for GCC warnings seen while compiling with W=1.Leon Romanovsky (3):
fs/btfrs: Fix -Wunused-but-set-variable warnings fs/btrfs: Fix -Wignored-qualifiers warnings fs/btrfs: Fix -Wmissing-prototypes warnings
The warnings from patch 2 and 3 got fixed recently, it's in the development branch that hasn't been pushed to linux-next yet.
Patch 1 reports unused variables, we get occasional patches that just silence the warning but it needs to be fixed properly (move setting feature bits out of sysfs context). As it's probably the last code warning with W=1 left I guess I'll apply it, I don't have ETA for the proper fix but at least this would save people time reporing it.