summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2009-12-06 20:10:49 +0900
committerIngo Molnar <mingo@elte.hu>2009-12-06 18:15:02 +0100
commit7691b1ec2e4a8d4bd88dcf88b29792399ebe1c91 (patch)
tree3b232372d2bd2a3aae58ccb37b36155d9917ab73 /tools/perf/util/header.c
parent180f95e29aa8782c019caa64ede2a28d8ab62564 (diff)
perf tools: Misc small fixes
- util/header.c "len" is aligned to 64. So, it tries to write the out of long_name buffer. So, this use "zero_buf" to write aligned area. - util/trace-event-read.c "size" is not including nul byte. So, this allocates it, and set '\0'. - util/trace-event-parse.c It needs parens to calc correct size. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <87d42s8iiu.fsf_-_@devron.myhome.or.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 4805e6dfd23..08b6759287f 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -187,7 +187,9 @@ static int do_write(int fd, const void *buf, size_t size)
static int __dsos__write_buildid_table(struct list_head *head, int fd)
{
+#define NAME_ALIGN 64
struct dso *pos;
+ static const char zero_buf[NAME_ALIGN];
list_for_each_entry(pos, head, node) {
int err;
@@ -197,14 +199,17 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd)
if (!pos->has_build_id)
continue;
len = pos->long_name_len + 1;
- len = ALIGN(len, 64);
+ len = ALIGN(len, NAME_ALIGN);
memset(&b, 0, sizeof(b));
memcpy(&b.build_id, pos->build_id, sizeof(pos->build_id));
b.header.size = sizeof(b) + len;
err = do_write(fd, &b, sizeof(b));
if (err < 0)
return err;
- err = do_write(fd, pos->long_name, len);
+ err = do_write(fd, pos->long_name, pos->long_name_len + 1);
+ if (err < 0)
+ return err;
+ err = do_write(fd, zero_buf, len - pos->long_name_len + 1);
if (err < 0)
return err;
}