Skip to content

Commit bc03c69

Browse files
oleg-nesterovtorvalds
authored andcommitted
coredump: introduce cn_vprintf()
Turn cn_printf(...) into cn_vprintf(va_list args), reintroduce cn_printf() as a trivial wrapper. This simplifies the next change and cn_vprintf() will have more callers. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Colin Walters <walters@verbum.org> Cc: Denys Vlasenko <vda.linux@googlemail.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Lennart Poettering <mzxreary@0pointer.de> Cc: Lucas De Marchi <lucas.de.marchi@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e7fd154 commit bc03c69

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

‎fs/coredump.c‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,13 @@ static int expand_corename(struct core_name *cn)
6969
return 0;
7070
}
7171

72-
static int cn_printf(struct core_name *cn, const char *fmt, ...)
72+
static int cn_vprintf(struct core_name *cn, const char *fmt, va_list arg)
7373
{
7474
char *cur;
7575
int need;
7676
int ret;
77-
va_list arg;
7877

79-
va_start(arg, fmt);
8078
need = vsnprintf(NULL, 0, fmt, arg);
81-
va_end(arg);
82-
8379
if (likely(need < cn->size - cn->used - 1))
8480
goto out_printf;
8581

@@ -89,16 +85,26 @@ static int cn_printf(struct core_name *cn, const char *fmt, ...)
8985

9086
out_printf:
9187
cur = cn->corename + cn->used;
92-
va_start(arg, fmt);
9388
vsnprintf(cur, need + 1, fmt, arg);
94-
va_end(arg);
9589
cn->used += need;
9690
return 0;
9791

9892
expand_fail:
9993
return ret;
10094
}
10195

96+
static int cn_printf(struct core_name *cn, const char *fmt, ...)
97+
{
98+
va_list arg;
99+
int ret;
100+
101+
va_start(arg, fmt);
102+
ret = cn_vprintf(cn, fmt, arg);
103+
va_end(arg);
104+
105+
return ret;
106+
}
107+
102108
static void cn_escape(char *str)
103109
{
104110
for (; *str; str++)

0 commit comments

Comments
 (0)