* [PATCH] mm: add printf attribute to shrinker_debugfs_name_alloc
@ 2023-10-06 20:30 Lucy Mielke
2023-10-10 0:50 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Lucy Mielke @ 2023-10-06 20:30 UTC (permalink / raw)
To: akpm, linux-mm; +Cc: linux-kernel
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]
Signed-off-by: Lucy Mielke <lucymielke@icloud.com>
---
mm/internal.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index 18e360fa53bc..e23f1ea55a8e 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -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);
--
2.42.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: add printf attribute to shrinker_debugfs_name_alloc
2023-10-06 20:30 [PATCH] mm: add printf attribute to shrinker_debugfs_name_alloc Lucy Mielke
@ 2023-10-10 0:50 ` Andrew Morton
2023-10-10 2:26 ` Qi Zheng
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2023-10-10 0:50 UTC (permalink / raw)
To: Lucy Mielke; +Cc: linux-mm, linux-kernel, Qi Zheng
On Fri, 6 Oct 2023 22:30:51 +0200 Lucy Mielke <lucymielke@icloud.com> 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
Fixes: c42d50aefd17 ("mm: shrinker: add infrastructure for dynamically allocating shrinker")
to this.
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -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);
>
> --
> 2.42.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: add printf attribute to shrinker_debugfs_name_alloc
2023-10-10 0:50 ` Andrew Morton
@ 2023-10-10 2:26 ` Qi Zheng
0 siblings, 0 replies; 3+ messages in thread
From: Qi Zheng @ 2023-10-10 2:26 UTC (permalink / raw)
To: Andrew Morton, Lucy Mielke; +Cc: linux-mm, linux-kernel
Hi,
On 2023/10/10 08:50, Andrew Morton wrote:
> On Fri, 6 Oct 2023 22:30:51 +0200 Lucy Mielke <lucymielke@icloud.com> 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
>
> Fixes: c42d50aefd17 ("mm: shrinker: add infrastructure for dynamically allocating shrinker")
>
> to this.
Thanks.
>
>> --- a/mm/internal.h
>> +++ b/mm/internal.h
>> @@ -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);
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:
diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h
index e4f93120e0ab..1a00be90d93a 100644
--- a/include/linux/shrinker.h
+++ b/include/linux/shrinker.h
@@ -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.
Reviewed-by: Qi Zheng <zhengqi.arch@bytedance.com>
Thanks,
Qi
>>
>> --
>> 2.42.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-10 2:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-06 20:30 [PATCH] mm: add printf attribute to shrinker_debugfs_name_alloc Lucy Mielke
2023-10-10 0:50 ` Andrew Morton
2023-10-10 2:26 ` Qi Zheng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.