mm: add printf attribute to shrinker_debugfs_name_alloc
Subsystems (3)
PATCH 1/1 mm: add printf attribute to shrinker_debugfs_name_alloc
This fixes a compiler warning when compiling an allyesconfig with W=1:
mm/internal.h:1235:9: error: function might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
--- mm/internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/internal.h +2 -2
@@ -1229,8 +1229,8 @@ unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, int priority);#ifdef CONFIG_SHRINKER_DEBUG -static inline int shrinker_debugfs_name_alloc (struct shrinker *shrinker, -const char *fmt,va_list ap) +static inline __printf(2, 0) int shrinker_debugfs_name_alloc( + struct shrinker *shrinker, const char *fmt, va_list ap) { shrinker->name = kvasprintf_const(GFP_KERNEL, fmt, ap);
Signature · 1 line
2.42.0
Andrew Morton
maintainerQuoted 4 lines · On Fri, 6 Oct 2023 22:30:51 +0200 Lucy Mielke <[email protected]> wrote:
This fixes a compiler warning when compiling an allyesconfig with W=1:
mm/internal.h:1235:9: error: function might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
Thanks. I added
to this.
Quoted 15 lines
mm/internal.h +2
-2@@ -1229,8 +1229,8 @@ unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, int priority);#ifdef CONFIG_SHRINKER_DEBUG -static inline int shrinker_debugfs_name_alloc (struct shrinker *shrinker, -const char *fmt,va_list ap) +static inline __printf(2, 0) int shrinker_debugfs_name_alloc( + struct shrinker *shrinker, const char *fmt, va_list ap) { shrinker->name = kvasprintf_const(GFP_KERNEL, fmt, ap);Signature · 1 line
2.42.0
Qi Zheng
Reviewed-byHi,
Quoted 4 lines · Andrew Morton
Quoted 2 lines · On Fri, 6 Oct 2023 22:30:51 +0200 Lucy Mielke <[email protected]> wrote:
This fixes a compiler warning when compiling an allyesconfig with W=1:
Quoted 8 lines
Quoted 2 lines
mm/internal.h:1235:9: error: function might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]Thanks. I added
Fixes c42d50aefd17 ("mm: shrinker: add infrastructure for dynamically allocating shrinker")to this.
Thanks.
Quoted 6 lines
Quoted 6 lines
mm/internal.h +0
-0@@ -1229,8 +1229,8 @@ unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, int priority);
Quoted 7 lines
mm/internal.h unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, · line 1235
Quoted 7 lines
mm/internal.h +2
-2#ifdef CONFIG_SHRINKER_DEBUG -static inline int shrinker_debugfs_name_alloc (struct shrinker *shrinker, -const char *fmt,va_list ap) +static inline __printf(2, 0) int shrinker_debugfs_name_alloc( + struct shrinker *shrinker, const char *fmt, va_list ap) { shrinker->name = kvasprintf_const(GFP_KERNEL, fmt, ap);
And there is also a warning introduced by c42d50aefd17:
mm/shrinker.c: In function 'shrinker_alloc':mm/shrinker.c:688:2: error: function 'shrinker_alloc' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]
688 | err = shrinker_debugfs_name_alloc(shrinker, fmt, ap);
| ^~~This also needs to be fixed:
include/linux/shrinker.h +1 -0
@@ -131,6 +131,7 @@ struct shrinker {*/ #define SHRINKER_NONSLAB BIT(4) +__printf(2, 3)struct shrinker *shrinker_alloc (unsigned int flags,const char *fmt, ...);void shrinker_register (struct shrinker *shrinker);void shrinker_free (struct shrinker *shrinker);
Other than that, LGTM.
Thanks,
Qi
Quoted 3 lines
Quoted 3 lines
Signature · 2 lines
-- 2.42.0