[PATCH v2 5/5] mm: simplify variadic args handling

Andrzej Hajda
2025-12-01T09:33:44Z

Changing argument type from va_list to struct va_format * allows
to simplify variadic argument handling with va_format_call helper.

Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
mm/slub.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 786c5a4195d4..12d8ec97eac5 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1135,27 +1135,16 @@ void skip_orig_size_check(struct kmem_cache *s, const void *object)
set_orig_size(s, (void *)object, s->object_size);
}

-static void __slab_bug(struct kmem_cache *s, const char *fmt, va_list argsp)
+static void __slab_bug(struct kmem_cache *s, const char *fmt, struct va_format *vaf)
{
- struct va_format vaf;
- va_list args;
-
- va_copy(args, argsp);
- vaf.fmt = fmt;
- vaf.va = &args;
pr_err("=============================================================================\n");
- pr_err("BUG %s (%s): %pV\n", s ? s->name : "<unknown>", print_tainted(), &vaf);
+ pr_err("BUG %s (%s): %pV\n", s ? s->name : "<unknown>", print_tainted(), vaf);
pr_err("-----------------------------------------------------------------------------\n\n");
- va_end(args);
}

static void slab_bug(struct kmem_cache *s, const char *fmt, ...)
{
- va_list args;
-
- va_start(args, fmt);
- __slab_bug(s, fmt, args);
- va_end(args);
+ va_format_call(fmt, __slab_bug, s, fmt, va_format_arg);
}

__printf(2, 3)
@@ -1252,14 +1241,10 @@ static void __slab_err(struct slab *slab)
static __printf(3, 4) void slab_err(struct kmem_cache *s, struct slab *slab,
const char *fmt, ...)
{
- va_list args;
-
if (slab_add_kunit_errors())
return;

- va_start(args, fmt);
- __slab_bug(s, fmt, args);
- va_end(args);
+ va_format_call(fmt, __slab_bug, s, fmt, va_format_arg);

__slab_err(slab);
}

--
2.43.0