aboutsummaryrefslogtreecommitdiffstats
path: root/fs/coredump.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-03 18:08:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:08:02 -0400
commitbc03c691aa86948af4e272ebdcdd4203018210f3 (patch)
tree3f15d82e7061ead660f39c78bbdc73c862c395fa /fs/coredump.c
parente7fd1549aeb83e34ee0955cdf5dee5d4088508f3 (diff)
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>
Diffstat (limited to 'fs/coredump.c')
-rw-r--r--fs/coredump.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/fs/coredump.c b/fs/coredump.c
index 11bc368e0017..c10a43aae220 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -69,17 +69,13 @@ static int expand_corename(struct core_name *cn)
69 return 0; 69 return 0;
70} 70}
71 71
72static int cn_printf(struct core_name *cn, const char *fmt, ...) 72static int cn_vprintf(struct core_name *cn, const char *fmt, va_list arg)
73{ 73{
74 char *cur; 74 char *cur;
75 int need; 75 int need;
76 int ret; 76 int ret;
77 va_list arg;
78 77
79 va_start(arg, fmt);
80 need = vsnprintf(NULL, 0, fmt, arg); 78 need = vsnprintf(NULL, 0, fmt, arg);
81 va_end(arg);
82
83 if (likely(need < cn->size - cn->used - 1)) 79 if (likely(need < cn->size - cn->used - 1))
84 goto out_printf; 80 goto out_printf;
85 81
@@ -89,9 +85,7 @@ static int cn_printf(struct core_name *cn, const char *fmt, ...)
89 85
90out_printf: 86out_printf:
91 cur = cn->corename + cn->used; 87 cur = cn->corename + cn->used;
92 va_start(arg, fmt);
93 vsnprintf(cur, need + 1, fmt, arg); 88 vsnprintf(cur, need + 1, fmt, arg);
94 va_end(arg);
95 cn->used += need; 89 cn->used += need;
96 return 0; 90 return 0;
97 91
@@ -99,6 +93,18 @@ expand_fail:
99 return ret; 93 return ret;
100} 94}
101 95
96static 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
102static void cn_escape(char *str) 108static void cn_escape(char *str)
103{ 109{
104 for (; *str; str++) 110 for (; *str; str++)