[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130515201222.GA14631@redhat.com>
Date: Wed, 15 May 2013 22:12:22 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andi Kleen <andi@...stfloor.org>,
Colin Walters <walters@...bum.org>,
Denys Vlasenko <vda.linux@...glemail.com>,
Jiri Slaby <jslaby@...e.cz>,
Lennart Poettering <mzxreary@...inter.de>,
Lucas De Marchi <lucas.de.marchi@...il.com>,
Neil Horman <nhorman@...driver.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 2/6] 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@...hat.com>
---
fs/coredump.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/fs/coredump.c b/fs/coredump.c
index 11bc368..c10a43a 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -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;
@@ -89,9 +85,7 @@ 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;
@@ -99,6 +93,18 @@ 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++)
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists