Skip to content

Commit

Permalink
coredump: introduce cn_vprintf()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Jul 3, 2013
1 parent e7fd154 commit bc03c69
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions fs/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,13 @@ static int expand_corename(struct core_name *cn)
return 0;
}

static int cn_printf(struct core_name *cn, const char *fmt, ...)
static int cn_vprintf(struct core_name *cn, const char *fmt, va_list arg)
{
char *cur;
int need;
int ret;
va_list arg;

va_start(arg, fmt);
need = vsnprintf(NULL, 0, fmt, arg);
va_end(arg);

if (likely(need < cn->size - cn->used - 1))
goto out_printf;

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

out_printf:
cur = cn->corename + cn->used;
va_start(arg, fmt);
vsnprintf(cur, need + 1, fmt, arg);
va_end(arg);
cn->used += need;
return 0;

expand_fail:
return ret;
}

static int cn_printf(struct core_name *cn, const char *fmt, ...)
{
va_list arg;
int ret;

va_start(arg, fmt);
ret = cn_vprintf(cn, fmt, arg);
va_end(arg);

return ret;
}

static void cn_escape(char *str)
{
for (; *str; str++)
Expand Down

0 comments on commit bc03c69

Please sign in to comment.