Skip to contentSkip to conversation

perf tools: Initialize output buffer in build_id__sprintf

PATCH Applied Jiri Olsa 3 participants 5 messages Nov 1, 2020 – Nov 3, 2020 perf events

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/2 perf tools: Initialize output buffer in build_id__sprintf

We display garbage for undefined build_id objects, because we don't initialize the output buffer.

---
 tools/perf/util/build-id.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/build-id.c +2 -0
index 8763772f1095..6b410c3d52dc 100644
@@ -102,6 +102,8 @@ int build_id__sprintf(const struct build_id *build_id, char *bf)
 	const u8 *raw = build_id->data;
 	size_t i;
 
+	bf[0] = 0x0;
+
 	for (i = 0; i < build_id->size; ++i) {
 		sprintf(bid, "%02x", *raw);
 		++raw;
Signature · 1 line
2.26.2
author reviewer
#1 lore raw

PATCH 2/2 perf tools: Add missing swap for ino_generation

We are missing swap for ino_generation field.

Fixes 5c5e854bc760 ("perf tools: Add attr->mmap2 support")
---
 tools/perf/util/session.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/session.c +1 -0
index 7a5f03764702..d20b16ee7377 100644
@@ -595,6 +595,7 @@ static void perf_event__mmap2_swap(union perf_event *event,
 	event->mmap2.maj   = bswap_32(event->mmap2.maj);
 	event->mmap2.min   = bswap_32(event->mmap2.min);
 	event->mmap2.ino   = bswap_64(event->mmap2.ino);
+	event->mmap2.ino_generation = bswap_64(event->mmap2.ino_generation);
 
 	if (sample_id_all) {
 		void *data = &event->mmap2.filename;
Signature · 1 line
2.26.2
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] perf tools: Add missing swap for ino_generation

Quoted 5 lines · Jiri Olsa

We are missing swap for ino_generation field.

Fixes 5c5e854bc760 ("perf tools: Add attr->mmap2 support")

Thanks
Namhyung

Quoted 19 lines
---
 tools/perf/util/session.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/session.c +1 -1
index 7a5f03764702..d20b16ee7377 100644
@@ -595,6 +595,7 @@ static void perf_event__mmap2_swap(union perf_event *event,
        event->mmap2.maj   = bswap_32(event->mmap2.maj);
        event->mmap2.min   = bswap_32(event->mmap2.min);
        event->mmap2.ino   = bswap_64(event->mmap2.ino);
+       event->mmap2.ino_generation = bswap_64(event->mmap2.ino_generation);
 
        if (sample_id_all) {
                void *data = &event->mmap2.filename;
--

2.26.2

maintainer Acked-by on v1 1/2
#3 lore raw
In reply to Jiri Olsa

Hi Jiri,

Quoted 5 lines · Jiri Olsa

We display garbage for undefined build_id objects, because we don't initialize the output buffer.

Thanks
Namhyung

Quoted 20 lines
---
 tools/perf/util/build-id.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/build-id.c +2 -1
index 8763772f1095..6b410c3d52dc 100644
@@ -102,6 +102,8 @@ int build_id__sprintf(const struct build_id *build_id, char *bf)
        const u8 *raw = build_id->data;
        size_t i;
 
+       bf[0] = 0x0;
+
        for (i = 0; i < build_id->size; ++i) {
                sprintf(bid, "%02x", *raw);
                ++raw;
--

2.26.2

maintainer Applied
#4 lore raw

Em Mon, Nov 02, 2020 at 10:50:00PM +0900, Namhyung Kim escreveu:

Quoted 10 lines

Hi Jiri,

Quoted 5 lines · Jiri Olsa

We display garbage for undefined build_id objects, because we don't initialize the output buffer.

Thanks, applied.

- Arnaldo

Quoted 24 lines

Thanks
Namhyung

Quoted 20 lines
---
 tools/perf/util/build-id.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/build-id.c +2 -1
index 8763772f1095..6b410c3d52dc 100644
@@ -102,6 +102,8 @@ int build_id__sprintf(const struct build_id *build_id, char *bf)
        const u8 *raw = build_id->data;
        size_t i;
 
+       bf[0] = 0x0;
+
        for (i = 0; i < build_id->size; ++i) {
                sprintf(bid, "%02x", *raw);
                ++raw;
--

2.26.2

Signature · 1 line
- Arnaldo