[PATCH v2 2/6] perf trace-event: Constify print arguments

Ian Rogers posted 6 patches 3 weeks, 1 day ago
There is a newer version of this series
[PATCH v2 2/6] perf trace-event: Constify print arguments
Posted by Ian Rogers 3 weeks, 1 day ago
Capture that these functions don't mutate their input.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/trace-event-parse.c | 4 ++--
 tools/perf/util/trace-event.h       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index f0332bd3a501..6f11ca5513e3 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -99,7 +99,7 @@ unsigned long long read_size(struct tep_event *event, void *ptr, int size)
 	return tep_read_number(event->tep, ptr, size);
 }
 
-void event_format__fprintf(struct tep_event *event,
+void event_format__fprintf(const struct tep_event *event,
 			   int cpu, void *data, int size, FILE *fp)
 {
 	struct tep_record record;
@@ -116,7 +116,7 @@ void event_format__fprintf(struct tep_event *event,
 	trace_seq_destroy(&s);
 }
 
-void event_format__print(struct tep_event *event,
+void event_format__print(const struct tep_event *event,
 			 int cpu, void *data, int size)
 {
 	return event_format__fprintf(event, cpu, data, size, stdout);
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index bbf8b26bc8da..084068fb36a1 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -39,10 +39,10 @@ trace_event__tp_format(const char *sys, const char *name);
 
 struct tep_event *trace_event__tp_format_id(int id);
 
-void event_format__fprintf(struct tep_event *event,
+void event_format__fprintf(const struct tep_event *event,
 			   int cpu, void *data, int size, FILE *fp);
 
-void event_format__print(struct tep_event *event,
+void event_format__print(const struct tep_event *event,
 			 int cpu, void *data, int size);
 
 int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size);
-- 
2.47.0.199.ga7371fff76-goog
Re: [PATCH v2 2/6] perf trace-event: Constify print arguments
Posted by Arnaldo Carvalho de Melo 2 weeks, 5 days ago
On Sat, Nov 02, 2024 at 09:53:56AM -0700, Ian Rogers wrote:
> Capture that these functions don't mutate their input.

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

- Arnaldo
 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/util/trace-event-parse.c | 4 ++--
>  tools/perf/util/trace-event.h       | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
> index f0332bd3a501..6f11ca5513e3 100644
> --- a/tools/perf/util/trace-event-parse.c
> +++ b/tools/perf/util/trace-event-parse.c
> @@ -99,7 +99,7 @@ unsigned long long read_size(struct tep_event *event, void *ptr, int size)
>  	return tep_read_number(event->tep, ptr, size);
>  }
>  
> -void event_format__fprintf(struct tep_event *event,
> +void event_format__fprintf(const struct tep_event *event,
>  			   int cpu, void *data, int size, FILE *fp)
>  {
>  	struct tep_record record;
> @@ -116,7 +116,7 @@ void event_format__fprintf(struct tep_event *event,
>  	trace_seq_destroy(&s);
>  }
>  
> -void event_format__print(struct tep_event *event,
> +void event_format__print(const struct tep_event *event,
>  			 int cpu, void *data, int size)
>  {
>  	return event_format__fprintf(event, cpu, data, size, stdout);
> diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
> index bbf8b26bc8da..084068fb36a1 100644
> --- a/tools/perf/util/trace-event.h
> +++ b/tools/perf/util/trace-event.h
> @@ -39,10 +39,10 @@ trace_event__tp_format(const char *sys, const char *name);
>  
>  struct tep_event *trace_event__tp_format_id(int id);
>  
> -void event_format__fprintf(struct tep_event *event,
> +void event_format__fprintf(const struct tep_event *event,
>  			   int cpu, void *data, int size, FILE *fp);
>  
> -void event_format__print(struct tep_event *event,
> +void event_format__print(const struct tep_event *event,
>  			 int cpu, void *data, int size);
>  
>  int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size);
> -- 
> 2.47.0.199.ga7371fff76-goog