mm: add printf attribute to shrinker_debugfs_name_alloc
authorLucy Mielke <lucymielke@icloud.com>
Fri, 6 Oct 2023 20:30:51 +0000 (22:30 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 18 Oct 2023 21:34:18 +0000 (14:34 -0700)
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]

[akpm@linux-foundation.org: fix shrinker_alloc() as welll per Qi Zheng]
Link: https://lkml.kernel.org/r/822387b7-4895-4e64-5806-0f56b5d6c447@bytedance.com
Link: https://lkml.kernel.org/r/ZSBue-3kM6gI6jCr@mainframe
Fixes: c42d50aefd17 ("mm: shrinker: add infrastructure for dynamically allocating shrinker")
Signed-off-by: Lucy Mielke <lucymielke@icloud.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/shrinker.h
mm/internal.h

index e4f93120e0ab8a4c4342e165f3b0ad3290b8cb2f..1a00be90d93a9fa0f6234dd4854b59027d1e0ffe 100644 (file)
@@ -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);
index 2b79da9deb64acfa80f6dd87cb1cab47ca368e33..d1f7a3c612fe59514975bc8522343197daef3ded 100644 (file)
@@ -1219,8 +1219,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);