perf machine: Pass buffer size to machine__mmap_name

Don't blindly assume that the size of the buffer is enough, use
snprintf.

Cc: Avi Kivity <avi@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Zhang, Yanmin <yanmin_zhang@linux.intel.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo
2010-04-27 21:19:05 -03:00
parent 23346f21b2
commit 48ea8f5470
4 changed files with 11 additions and 11 deletions

View File

@@ -629,14 +629,14 @@ void machines__process(struct rb_root *self, machine__process_t process, void *d
}
}
char *machine__mmap_name(struct machine *self, char *buff)
char *machine__mmap_name(struct machine *self, char *bf, size_t size)
{
if (machine__is_host(self))
sprintf(buff, "[%s]", "kernel.kallsyms");
snprintf(bf, size, "[%s]", "kernel.kallsyms");
else if (machine__is_default_guest(self))
sprintf(buff, "[%s]", "guest.kernel.kallsyms");
snprintf(bf, size, "[%s]", "guest.kernel.kallsyms");
else
sprintf(buff, "[%s.%d]", "guest.kernel.kallsyms", self->pid);
snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms", self->pid);
return buff;
return bf;
}