Skip to contentSkip to conversation

perf trace: Remove return value of trace__fprintf_tp_fields

PATCH Superseded Benjamin Peterson 3 participants 7 messages Dec 13, 2024 – Jan 24, 2025 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf trace: Remove return value of trace__fprintf_tp_fields

The return value of this function was meaningless and therefore ignored by the caller. Remove it.

---
This is a small followup cleanup to my earlier commit 5fb8e56542a3 ("perf
trace: avoid garbage when not printing a trace event's arguments").

---
 tools/perf/builtin-trace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/builtin-trace.c +3 -3
index 6a1a128fe645014d0347ad4ec3e0c9e77ec59aee..246be66fd59a4b9d76e4d3c42b68d0a444ca366a 100644
@@ -3022,8 +3022,8 @@ static void bpf_output__fprintf(struct trace *trace,
 	++trace->nr_events_printed;
 }
 
-static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
-				       struct thread *thread, void *augmented_args, int augmented_args_size)
+static void trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
+				     struct thread *thread, void *augmented_args, int augmented_args_size)
 {
 	char bf[2048];
 	size_t size = sizeof(bf);
@@ -3088,7 +3088,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
 		printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
 	}
 
-	return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
+	fprintf(trace->output, "%.*s", (int)printed, bf);
 }
 
 static int trace__event_handler(struct trace *trace, struct evsel *evsel,

---
base-commit: eefa7a9c069908412f8f5d15833901d1b46ae1b2
change-id: 20241212-void-fprintf_tp_fields-8aaae2f5525f

Best regards,

Signature · 1 line
Benjamin Peterson <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw

Hello Benjamin,

Quoted 41 lines · Benjamin Peterson

The return value of this function was meaningless and therefore ignored by the caller. Remove it.

---
This is a small followup cleanup to my earlier commit 5fb8e56542a3 ("perf
trace: avoid garbage when not printing a trace event's arguments").

---
 tools/perf/builtin-trace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/builtin-trace.c +3 -4
index 6a1a128fe645014d0347ad4ec3e0c9e77ec59aee..246be66fd59a4b9d76e4d3c42b68d0a444ca366a 100644
@@ -3022,8 +3022,8 @@ static void bpf_output__fprintf(struct trace *trace,
        ++trace->nr_events_printed;
 }
 
-static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
-                                      struct thread *thread, void *augmented_args, int augmented_args_size)
+static void trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
+                                    struct thread *thread, void *augmented_args, int augmented_args_size)
 {
        char bf[2048];
        size_t size = sizeof(bf);
@@ -3088,7 +3088,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
                printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
        }
 
-       return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
+       fprintf(trace->output, "%.*s", (int)printed, bf);
 }
 
 static int trace__event_handler(struct trace *trace, struct evsel *evsel,
 
---

base-commit: eefa7a9c069908412f8f5d15833901d1b46ae1b2
change-id: 20241212-void-fprintf_tp_fields-8aaae2f5525f

Quoted 5 lines

Best regards,
--
Benjamin Peterson <[email protected]>

Thank you for the follow-up patch, LGTM. Built and tested.

perf $ ./perf test "perf trace"
109: perf trace enum augmentation tests : Ok
110: perf trace exit race : Ok

Thanks,
Howard

#2 lore raw

Hello fellow maintainers,

Just a slight ping.

Thanks,
Howard

Quoted 61 lines · Howard Chu

Hello Benjamin,

Quoted 41 lines · Benjamin Peterson

The return value of this function was meaningless and therefore ignored by the caller. Remove it.

---
This is a small followup cleanup to my earlier commit 5fb8e56542a3 ("perf
trace: avoid garbage when not printing a trace event's arguments").

---
 tools/perf/builtin-trace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/builtin-trace.c +3 -4
index 6a1a128fe645014d0347ad4ec3e0c9e77ec59aee..246be66fd59a4b9d76e4d3c42b68d0a444ca366a 100644
@@ -3022,8 +3022,8 @@ static void bpf_output__fprintf(struct trace *trace,
        ++trace->nr_events_printed;
 }
 
-static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
-                                      struct thread *thread, void *augmented_args, int augmented_args_size)
+static void trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
+                                    struct thread *thread, void *augmented_args, int augmented_args_size)
 {
        char bf[2048];
        size_t size = sizeof(bf);
@@ -3088,7 +3088,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
                printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
        }
 
-       return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
+       fprintf(trace->output, "%.*s", (int)printed, bf);
 }
 
 static int trace__event_handler(struct trace *trace, struct evsel *evsel,
 
---

base-commit: eefa7a9c069908412f8f5d15833901d1b46ae1b2
change-id: 20241212-void-fprintf_tp_fields-8aaae2f5525f

Quoted 5 lines

Best regards,
--
Benjamin Peterson <[email protected]>

Thank you for the follow-up patch, LGTM. Built and tested.

perf $ ./perf test "perf trace"
109: perf trace enum augmentation tests : Ok
110: perf trace exit race : Ok

Thanks,
Howard

maintainer
#3 lore raw

Hello,

Quoted 3 lines · Howard Chu

Hello fellow maintainers,

Just a slight ping.

Thanks for the reminder.

Quoted 12 lines

Thanks,
Howard

Quoted 7 lines · Howard Chu

Hello Benjamin,

Quoted 3 lines · Benjamin Peterson

The return value of this function was meaningless and therefore ignored by the caller. Remove it.

In fact, I don't see the reason to merge this, as it's the convention to return the number of characters it prints. Yes, it's not used but not much reason to remove it.

Thanks,
Namhyung

Quoted 54 lines
Quoted 54 lines
Quoted 38 lines

---
This is a small followup cleanup to my earlier commit 5fb8e56542a3 ("perf
trace: avoid garbage when not printing a trace event's arguments").

---
 tools/perf/builtin-trace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/builtin-trace.c +3 -4
index 6a1a128fe645014d0347ad4ec3e0c9e77ec59aee..246be66fd59a4b9d76e4d3c42b68d0a444ca366a 100644
@@ -3022,8 +3022,8 @@ static void bpf_output__fprintf(struct trace *trace,
        ++trace->nr_events_printed;
 }
 
-static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
-                                      struct thread *thread, void *augmented_args, int augmented_args_size)
+static void trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
+                                    struct thread *thread, void *augmented_args, int augmented_args_size)
 {
        char bf[2048];
        size_t size = sizeof(bf);
@@ -3088,7 +3088,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
                printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
        }
 
-       return printed + fprintf(trace->output, "%.*s", (int)printed, bf);
+       fprintf(trace->output, "%.*s", (int)printed, bf);
 }
 
 static int trace__event_handler(struct trace *trace, struct evsel *evsel,
 
---

base-commit: eefa7a9c069908412f8f5d15833901d1b46ae1b2
change-id: 20241212-void-fprintf_tp_fields-8aaae2f5525f

Quoted 5 lines

Best regards,
--
Benjamin Peterson <[email protected]>

Thank you for the follow-up patch, LGTM. Built and tested.

perf $ ./perf test "perf trace"
109: perf trace enum augmentation tests : Ok
110: perf trace exit race : Ok

Thanks,
Howard

#4 lore raw
Quoted 9 lines · Namhyung Kim

Hello,

Quoted 3 lines · Howard Chu

Hello fellow maintainers,

Just a slight ping.

Thanks for the reminder.

Thanks for taking a look.

Quoted 9 lines
Quoted 9 lines

Thanks,
Howard

Quoted 3 lines · Howard Chu

Hello Benjamin,

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines · Benjamin Peterson
Quoted 3 lines

The return value of this function was meaningless and therefore ignored by the caller. Remove it.

In fact, I don't see the reason to merge this, as it's the convention to return the number of characters it prints. Yes, it's not used but not much reason to remove it.

The main reason to remove the return value is that it has no useful interpretation and is therefore confusing. To wit, the function returns two times the number of bytes it prints.

maintainer
#5 lore raw
Quoted 27 lines · Benjamin Peterson
Quoted 9 lines · Namhyung Kim

Hello,

Quoted 3 lines · Howard Chu

Hello fellow maintainers,

Just a slight ping.

Thanks for the reminder.

Thanks for taking a look.

Quoted 14 lines
Quoted 13 lines

Thanks,
Howard

Quoted 7 lines · Howard Chu

Hello Benjamin,

Quoted 3 lines · Benjamin Peterson

The return value of this function was meaningless and therefore ignored by the caller. Remove it.

Quoted 7 lines
Quoted 3 lines

In fact, I don't see the reason to merge this, as it's the convention to return the number of characters it prints. Yes, it's not used but not much reason to remove it.

The main reason to remove the return value is that it has no useful interpretation and is therefore confusing. To wit, the function returns two times the number of bytes it prints.

Oh, ok. Then please just fix it to return the correct number.

Thanks,
Namhyung

#6 lore raw
Quoted 33 lines · Namhyung Kim
Quoted 31 lines · Benjamin Peterson
Quoted 9 lines · Namhyung Kim

Hello,

Quoted 3 lines · Howard Chu

Hello fellow maintainers,

Just a slight ping.

Thanks for the reminder.

Thanks for taking a look.

Quoted 17 lines
Quoted 13 lines

Thanks,
Howard

Quoted 7 lines · Howard Chu

Hello Benjamin,

Quoted 3 lines · Benjamin Peterson

The return value of this function was meaningless and therefore ignored by the caller. Remove it.

In fact, I don't see the reason to merge this, as it's the convention to return the number of characters it prints. Yes, it's not used but not much reason to remove it.

Quoted 5 lines
Quoted 3 lines

The main reason to remove the return value is that it has no useful interpretation and is therefore confusing. To wit, the function returns two times the number of bytes it prints.

Oh, ok. Then please just fix it to return the correct number.

Alright, I've submitted v2 that simply propagates the return value of fprintf.