* [PATCH 0/2] bcache paches for Linux v5.16 (2nd wave) @ 2021-10-29 6:08 Coly Li 2021-10-29 6:08 ` [PATCH 1/2] bcache: move uapi header bcache.h to bcache code directory Coly Li 2021-10-29 6:08 ` [PATCH 2/2] bcache: replace snprintf in show functions with sysfs_emit Coly Li 0 siblings, 2 replies; 4+ messages in thread From: Coly Li @ 2021-10-29 6:08 UTC (permalink / raw) To: axbeo; +Cc: linux-bcache, linux-block, Coly Li Hi Jens, This is the second wave of bcache patches for Linux v5.16. The first patch is suggested by Arnd Bergmann and Christoph Hellwig that the bcache.h should not belong to include/uapi/ directory, and I compose the change. The second patch is code cleanup to remove coccicheck warning which suggests to use scnprintf to replace snprintf(), Qing Wang posts the change to remove the warning by using sysfs_emit(). Please take them for Linux v5.16 and thanks in advance. Coly Li --- Coly Li (1): bcache: move uapi header bcache.h to bcache code directory Qing Wang (1): bcache: replace snprintf in show functions with sysfs_emit drivers/md/bcache/bcache.h | 2 +- .../md/bcache/bcache_ondisk.h | 0 drivers/md/bcache/bset.h | 2 +- drivers/md/bcache/features.c | 2 +- drivers/md/bcache/features.h | 3 ++- drivers/md/bcache/sysfs.h | 18 ++++++++++++++++-- drivers/md/bcache/util.h | 17 ----------------- 7 files changed, 21 insertions(+), 23 deletions(-) rename include/uapi/linux/bcache.h => drivers/md/bcache/bcache_ondisk.h (100%) -- 2.31.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] bcache: move uapi header bcache.h to bcache code directory 2021-10-29 6:08 [PATCH 0/2] bcache paches for Linux v5.16 (2nd wave) Coly Li @ 2021-10-29 6:08 ` Coly Li 2021-10-29 6:08 ` [PATCH 2/2] bcache: replace snprintf in show functions with sysfs_emit Coly Li 1 sibling, 0 replies; 4+ messages in thread From: Coly Li @ 2021-10-29 6:08 UTC (permalink / raw) To: axbeo Cc: linux-bcache, linux-block, Coly Li, Arnd Bergmann, Christoph Hellwig The header file include/uapi/linux/bcache.h is not really a user space API heaer. This file defines the ondisk format of bcache internal meta data but no one includes it from user space, bcache-tools has its own copy of this header with minor modification. Therefore, this patch moves include/uapi/linux/bcache.h to bcache code directory as drivers/md/bcache/bcache_ondisk.h. Suggested-by: Arnd Bergmann <arnd@kernel.org> Suggested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Coly Li <colyli@suse.de> --- drivers/md/bcache/bcache.h | 2 +- .../uapi/linux/bcache.h => drivers/md/bcache/bcache_ondisk.h | 0 drivers/md/bcache/bset.h | 2 +- drivers/md/bcache/features.c | 2 +- drivers/md/bcache/features.h | 3 ++- 5 files changed, 5 insertions(+), 4 deletions(-) rename include/uapi/linux/bcache.h => drivers/md/bcache/bcache_ondisk.h (100%) diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 941685409c68..9ed9c955add7 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -178,7 +178,6 @@ #define pr_fmt(fmt) "bcache: %s() " fmt, __func__ -#include <linux/bcache.h> #include <linux/bio.h> #include <linux/kobject.h> #include <linux/list.h> @@ -190,6 +189,7 @@ #include <linux/workqueue.h> #include <linux/kthread.h> +#include "bcache_ondisk.h" #include "bset.h" #include "util.h" #include "closure.h" diff --git a/include/uapi/linux/bcache.h b/drivers/md/bcache/bcache_ondisk.h similarity index 100% rename from include/uapi/linux/bcache.h rename to drivers/md/bcache/bcache_ondisk.h diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index a50dcfda656f..d795c84246b0 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h @@ -2,10 +2,10 @@ #ifndef _BCACHE_BSET_H #define _BCACHE_BSET_H -#include <linux/bcache.h> #include <linux/kernel.h> #include <linux/types.h> +#include "bcache_ondisk.h" #include "util.h" /* for time_stats */ /* diff --git a/drivers/md/bcache/features.c b/drivers/md/bcache/features.c index 6d2b7b84a7b7..634922c5601d 100644 --- a/drivers/md/bcache/features.c +++ b/drivers/md/bcache/features.c @@ -6,7 +6,7 @@ * Copyright 2020 Coly Li <colyli@suse.de> * */ -#include <linux/bcache.h> +#include "bcache_ondisk.h" #include "bcache.h" #include "features.h" diff --git a/drivers/md/bcache/features.h b/drivers/md/bcache/features.h index d1c8fd3977fc..09161b89c63e 100644 --- a/drivers/md/bcache/features.h +++ b/drivers/md/bcache/features.h @@ -2,10 +2,11 @@ #ifndef _BCACHE_FEATURES_H #define _BCACHE_FEATURES_H -#include <linux/bcache.h> #include <linux/kernel.h> #include <linux/types.h> +#include "bcache_ondisk.h" + #define BCH_FEATURE_COMPAT 0 #define BCH_FEATURE_RO_COMPAT 1 #define BCH_FEATURE_INCOMPAT 2 -- 2.31.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] bcache: replace snprintf in show functions with sysfs_emit 2021-10-29 6:08 [PATCH 0/2] bcache paches for Linux v5.16 (2nd wave) Coly Li 2021-10-29 6:08 ` [PATCH 1/2] bcache: move uapi header bcache.h to bcache code directory Coly Li @ 2021-10-29 6:08 ` Coly Li 1 sibling, 0 replies; 4+ messages in thread From: Coly Li @ 2021-10-29 6:08 UTC (permalink / raw) To: axbeo; +Cc: linux-bcache, linux-block, Qing Wang, Coly Li From: Qing Wang <wangqing@vivo.com> coccicheck complains about the use of snprintf() in sysfs show functions. Fix the following coccicheck warning: drivers/md/bcache/sysfs.h:54:12-20: WARNING: use scnprintf or sprintf. Implement sysfs_print() by sysfs_emit() and remove snprint() since no one uses it any more. Suggested-by: Coly Li <colyli@suse.de> Signed-off-by: Qing Wang <wangqing@vivo.com> Signed-off-by: Coly Li <colyli@suse.de> --- drivers/md/bcache/sysfs.h | 18 ++++++++++++++++-- drivers/md/bcache/util.h | 17 ----------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h index 215df32f567b..c1752ba2e05b 100644 --- a/drivers/md/bcache/sysfs.h +++ b/drivers/md/bcache/sysfs.h @@ -51,13 +51,27 @@ STORE(fn) \ #define sysfs_printf(file, fmt, ...) \ do { \ if (attr == &sysfs_ ## file) \ - return snprintf(buf, PAGE_SIZE, fmt "\n", __VA_ARGS__); \ + return sysfs_emit(buf, fmt "\n", __VA_ARGS__); \ } while (0) #define sysfs_print(file, var) \ do { \ if (attr == &sysfs_ ## file) \ - return snprint(buf, PAGE_SIZE, var); \ + return sysfs_emit(buf, \ + __builtin_types_compatible_p(typeof(var), int) \ + ? "%i\n" : \ + __builtin_types_compatible_p(typeof(var), unsigned int) \ + ? "%u\n" : \ + __builtin_types_compatible_p(typeof(var), long) \ + ? "%li\n" : \ + __builtin_types_compatible_p(typeof(var), unsigned long)\ + ? "%lu\n" : \ + __builtin_types_compatible_p(typeof(var), int64_t) \ + ? "%lli\n" : \ + __builtin_types_compatible_p(typeof(var), uint64_t) \ + ? "%llu\n" : \ + __builtin_types_compatible_p(typeof(var), const char *) \ + ? "%s\n" : "%i\n", var); \ } while (0) #define sysfs_hprint(file, val) \ diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index 6274d6a17e5e..cdb165517d0b 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h @@ -340,23 +340,6 @@ static inline int bch_strtoul_h(const char *cp, long *res) _r; \ }) -#define snprint(buf, size, var) \ - snprintf(buf, size, \ - __builtin_types_compatible_p(typeof(var), int) \ - ? "%i\n" : \ - __builtin_types_compatible_p(typeof(var), unsigned int) \ - ? "%u\n" : \ - __builtin_types_compatible_p(typeof(var), long) \ - ? "%li\n" : \ - __builtin_types_compatible_p(typeof(var), unsigned long)\ - ? "%lu\n" : \ - __builtin_types_compatible_p(typeof(var), int64_t) \ - ? "%lli\n" : \ - __builtin_types_compatible_p(typeof(var), uint64_t) \ - ? "%llu\n" : \ - __builtin_types_compatible_p(typeof(var), const char *) \ - ? "%s\n" : "%i\n", var) - ssize_t bch_hprint(char *buf, int64_t v); bool bch_is_zero(const char *p, size_t n); -- 2.31.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 0/2] bcache paches for Linux v5.16 (2nd wave) @ 2021-10-29 6:09 Coly Li 2021-10-29 6:09 ` [PATCH 2/2] bcache: replace snprintf in show functions with sysfs_emit Coly Li 0 siblings, 1 reply; 4+ messages in thread From: Coly Li @ 2021-10-29 6:09 UTC (permalink / raw) To: axboe; +Cc: linux-bcache, linux-block, Coly Li Hi Jens, This is the second wave of bcache patches for Linux v5.16. The first patch is suggested by Arnd Bergmann and Christoph Hellwig that the bcache.h should not belong to include/uapi/ directory, and I compose the change. The second patch is code cleanup to remove coccicheck warning which suggests to use scnprintf to replace snprintf(), Qing Wang posts the change to remove the warning by using sysfs_emit(). Please take them for Linux v5.16 and thanks in advance. Coly Li --- Coly Li (1): bcache: move uapi header bcache.h to bcache code directory Qing Wang (1): bcache: replace snprintf in show functions with sysfs_emit drivers/md/bcache/bcache.h | 2 +- .../md/bcache/bcache_ondisk.h | 0 drivers/md/bcache/bset.h | 2 +- drivers/md/bcache/features.c | 2 +- drivers/md/bcache/features.h | 3 ++- drivers/md/bcache/sysfs.h | 18 ++++++++++++++++-- drivers/md/bcache/util.h | 17 ----------------- 7 files changed, 21 insertions(+), 23 deletions(-) rename include/uapi/linux/bcache.h => drivers/md/bcache/bcache_ondisk.h (100%) -- 2.31.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] bcache: replace snprintf in show functions with sysfs_emit 2021-10-29 6:09 [PATCH 0/2] bcache paches for Linux v5.16 (2nd wave) Coly Li @ 2021-10-29 6:09 ` Coly Li 0 siblings, 0 replies; 4+ messages in thread From: Coly Li @ 2021-10-29 6:09 UTC (permalink / raw) To: axboe; +Cc: linux-bcache, linux-block, Qing Wang, Coly Li From: Qing Wang <wangqing@vivo.com> coccicheck complains about the use of snprintf() in sysfs show functions. Fix the following coccicheck warning: drivers/md/bcache/sysfs.h:54:12-20: WARNING: use scnprintf or sprintf. Implement sysfs_print() by sysfs_emit() and remove snprint() since no one uses it any more. Suggested-by: Coly Li <colyli@suse.de> Signed-off-by: Qing Wang <wangqing@vivo.com> Signed-off-by: Coly Li <colyli@suse.de> --- drivers/md/bcache/sysfs.h | 18 ++++++++++++++++-- drivers/md/bcache/util.h | 17 ----------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h index 215df32f567b..c1752ba2e05b 100644 --- a/drivers/md/bcache/sysfs.h +++ b/drivers/md/bcache/sysfs.h @@ -51,13 +51,27 @@ STORE(fn) \ #define sysfs_printf(file, fmt, ...) \ do { \ if (attr == &sysfs_ ## file) \ - return snprintf(buf, PAGE_SIZE, fmt "\n", __VA_ARGS__); \ + return sysfs_emit(buf, fmt "\n", __VA_ARGS__); \ } while (0) #define sysfs_print(file, var) \ do { \ if (attr == &sysfs_ ## file) \ - return snprint(buf, PAGE_SIZE, var); \ + return sysfs_emit(buf, \ + __builtin_types_compatible_p(typeof(var), int) \ + ? "%i\n" : \ + __builtin_types_compatible_p(typeof(var), unsigned int) \ + ? "%u\n" : \ + __builtin_types_compatible_p(typeof(var), long) \ + ? "%li\n" : \ + __builtin_types_compatible_p(typeof(var), unsigned long)\ + ? "%lu\n" : \ + __builtin_types_compatible_p(typeof(var), int64_t) \ + ? "%lli\n" : \ + __builtin_types_compatible_p(typeof(var), uint64_t) \ + ? "%llu\n" : \ + __builtin_types_compatible_p(typeof(var), const char *) \ + ? "%s\n" : "%i\n", var); \ } while (0) #define sysfs_hprint(file, val) \ diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index 6274d6a17e5e..cdb165517d0b 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h @@ -340,23 +340,6 @@ static inline int bch_strtoul_h(const char *cp, long *res) _r; \ }) -#define snprint(buf, size, var) \ - snprintf(buf, size, \ - __builtin_types_compatible_p(typeof(var), int) \ - ? "%i\n" : \ - __builtin_types_compatible_p(typeof(var), unsigned int) \ - ? "%u\n" : \ - __builtin_types_compatible_p(typeof(var), long) \ - ? "%li\n" : \ - __builtin_types_compatible_p(typeof(var), unsigned long)\ - ? "%lu\n" : \ - __builtin_types_compatible_p(typeof(var), int64_t) \ - ? "%lli\n" : \ - __builtin_types_compatible_p(typeof(var), uint64_t) \ - ? "%llu\n" : \ - __builtin_types_compatible_p(typeof(var), const char *) \ - ? "%s\n" : "%i\n", var) - ssize_t bch_hprint(char *buf, int64_t v); bool bch_is_zero(const char *p, size_t n); -- 2.31.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-29 6:09 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-10-29 6:08 [PATCH 0/2] bcache paches for Linux v5.16 (2nd wave) Coly Li 2021-10-29 6:08 ` [PATCH 1/2] bcache: move uapi header bcache.h to bcache code directory Coly Li 2021-10-29 6:08 ` [PATCH 2/2] bcache: replace snprintf in show functions with sysfs_emit Coly Li 2021-10-29 6:09 [PATCH 0/2] bcache paches for Linux v5.16 (2nd wave) Coly Li 2021-10-29 6:09 ` [PATCH 2/2] bcache: replace snprintf in show functions with sysfs_emit Coly Li
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).