lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <14f09d56-d4f1-8602-6a98-5588cbef8c81@intel.com>
Date:   Fri, 12 May 2023 13:33:20 +0300
From:   Adrian Hunter <adrian.hunter@...el.com>
To:     Yang Jihong <yangjihong1@...wei.com>, peterz@...radead.org,
        mingo@...hat.com, acme@...nel.org, mark.rutland@....com,
        alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
        namhyung@...nel.org, irogers@...gle.com, anshuman.khandual@....com,
        jesussanp@...gle.com, linux-perf-users@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/4] perf trace-event-info: Add tracepoint_id_to_name()
 helper

On 11/05/23 10:51, Yang Jihong wrote:
> Add tracepoint_id_to_name() helper to search for the trace events directory
> by given event id and return the corresponding tracepoint.
> 
> Signed-off-by: Yang Jihong <yangjihong1@...wei.com>
> ---
>  tools/perf/util/trace-event-info.c | 11 +++++++++++
>  tools/perf/util/trace-event.h      |  6 ++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
> index c24b3a15e319..a5c65cb02a28 100644
> --- a/tools/perf/util/trace-event-info.c
> +++ b/tools/perf/util/trace-event-info.c
> @@ -466,6 +466,17 @@ static struct tracepoint_path *tracepoint_id_to_path(u64 config)
>  	return NULL;
>  }
>  
> +char *tracepoint_id_to_name(u64 config)
> +{
> +	char *buf = NULL;
> +	struct tracepoint_path *path = tracepoint_id_to_path(config);

It is considered slightly nicer to put local declarations
in descending order of line length. i.e.

	struct tracepoint_path *path = tracepoint_id_to_path(config);
	char *buf = NULL;

> +
> +	if ((path != NULL) && (asprintf(&buf, "%s:%s", path->system, path->name) > 0))

The parentheses are unnecessary and kernel style tends to avoid "!= NULL"
i.e.

	if (path && asprintf(&buf, "%s:%s", path->system, path->name) > 0)

> +		return buf;
> +
> +	return NULL;
> +}
> +
>  static struct tracepoint_path *tracepoint_name_to_path(const char *name)
>  {
>  	struct tracepoint_path *path = zalloc(sizeof(*path));
> diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
> index a0cff184b1cd..a69ee29419f3 100644
> --- a/tools/perf/util/trace-event.h
> +++ b/tools/perf/util/trace-event.h
> @@ -62,6 +62,12 @@ unsigned long long eval_flag(const char *flag);
>  
>  int read_tracing_data(int fd, struct list_head *pattrs);
>  
> +/*
> + * Return the tracepoint name in the format "subsystem:event_name",
> + * callers should free the returned string.
> + */
> +char *tracepoint_id_to_name(u64 config);
> +
>  struct tracing_data {
>  	/* size is only valid if temp is 'true' */
>  	ssize_t size;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ