diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-03-14 11:29:29 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-03-14 11:36:19 -0400 |
commit | e7f01d1e3d8d501deb8abeaa269d5d48a703b8b0 (patch) | |
tree | 2746465309fd16392ed7c6265dea53366c6e52c7 /tools/perf/util/header.c | |
parent | b832796caa1fda8516464a003c8c7cc547bc20c2 (diff) |
perf tools: Use scnprintf where applicable
Several places were expecting that the value returned was the number of
characters printed, not what would be printed if there was space.
Fix it by using the scnprintf and vscnprintf variants we inherited from
the kernel sources.
Some corner cases where the number of printed characters were not
accounted were fixed too.
Reported-by: Anton Blanchard <anton@samba.org>
Cc: Anton Blanchard <anton@samba.org>
Cc: Eric B Munson <emunson@mgebm.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Yanmin Zhang <yanmin_zhang@linux.intel.com>
Cc: stable@kernel.org
Link: http://lkml.kernel.org/n/tip-kwxo2eh29cxmd8ilixi2005x@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index ecd7f4dd7eea..14bb035c5fd9 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -280,7 +280,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
280 | if (realname == NULL || filename == NULL || linkname == NULL) | 280 | if (realname == NULL || filename == NULL || linkname == NULL) |
281 | goto out_free; | 281 | goto out_free; |
282 | 282 | ||
283 | len = snprintf(filename, size, "%s%s%s", | 283 | len = scnprintf(filename, size, "%s%s%s", |
284 | debugdir, is_kallsyms ? "/" : "", realname); | 284 | debugdir, is_kallsyms ? "/" : "", realname); |
285 | if (mkdir_p(filename, 0755)) | 285 | if (mkdir_p(filename, 0755)) |
286 | goto out_free; | 286 | goto out_free; |
@@ -295,7 +295,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
295 | goto out_free; | 295 | goto out_free; |
296 | } | 296 | } |
297 | 297 | ||
298 | len = snprintf(linkname, size, "%s/.build-id/%.2s", | 298 | len = scnprintf(linkname, size, "%s/.build-id/%.2s", |
299 | debugdir, sbuild_id); | 299 | debugdir, sbuild_id); |
300 | 300 | ||
301 | if (access(linkname, X_OK) && mkdir_p(linkname, 0755)) | 301 | if (access(linkname, X_OK) && mkdir_p(linkname, 0755)) |