tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline
PATCH 1/1 tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline
In order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. That prefix will be "tep_".
This patch renames struct cmdline to struct tep_cmdline.
Signed-off-by Tzvetomir Stoyanov <[email protected]>
--- tools/lib/traceevent/event-parse-local.h | 4 +-- tools/lib/traceevent/event-parse.c | 36 ++++++++++++------------ tools/lib/traceevent/event-parse.h | 8 +++--- 3 files changed, 24 insertions(+), 24 deletions(-)
tools/lib/traceevent/event-parse-local.h +2 -2
@@ -7,7 +7,7 @@#ifndef _PARSE_EVENTS_INT_H#define _PARSE_EVENTS_INT_H -struct cmdline ; +struct tep_cmdline ;struct cmdline_list ;struct func_map ;struct func_list ;
@@ -36,7 +36,7 @@ struct tep_handle {int long_size;int page_size; -struct cmdline *cmdlines; +struct tep_cmdline *cmdlines;struct cmdline_list *cmdlist;int cmdline_count;
tools/lib/traceevent/event-parse.c +18 -18
@@ -139,15 +139,15 @@ struct tep_print_arg *alloc_arg(void)return calloc (1 ,sizeof (struct tep_print_arg )); } -struct cmdline { +struct tep_cmdline {char *comm;int pid; };static int cmdline_cmp (const void *a,const void *b) { -const struct cmdline *ca = a; -const struct cmdline *cb = b; +const struct tep_cmdline *ca = a; +const struct tep_cmdline *cb = b;if (ca->pid < cb->pid)return -1 ;
@@ -167,7 +167,7 @@ static int cmdline_init(struct tep_handle *pevent) {struct cmdline_list *cmdlist = pevent->cmdlist;struct cmdline_list *item; -struct cmdline *cmdlines; +struct tep_cmdline *cmdlines;int i; cmdlines =malloc (sizeof (*cmdlines) * pevent->cmdline_count);
@@ -194,8 +194,8 @@ static int cmdline_init(struct tep_handle *pevent)static const char *find_cmdline (struct tep_handle *pevent,int pid) { -const struct cmdline *comm; -struct cmdline key; +const struct tep_cmdline *comm; +struct tep_cmdline key;if (!pid)return "<idle>" ;
@@ -223,8 +223,8 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid)*/ int tep_pid_is_registered (struct tep_handle *pevent,int pid) { -const struct cmdline *comm; -struct cmdline key; +const struct tep_cmdline *comm; +struct tep_cmdline key;if (!pid)return 1 ;
@@ -250,9 +250,9 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid)static int add_new_comm (struct tep_handle *pevent,const char *comm,int pid,bool override) { -struct cmdline *cmdlines = pevent->cmdlines; -struct cmdline *cmdline; -struct cmdline key; +struct tep_cmdline *cmdlines = pevent->cmdlines; +struct tep_cmdline *cmdline; +struct tep_cmdline key;char *new_comm;if (!pid)
@@ -5345,8 +5345,8 @@ const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid)return comm; } -static struct cmdline * -pid_from_cmdlist (struct tep_handle *pevent,const char *comm,struct cmdline *next) +static struct tep_cmdline * +pid_from_cmdlist (struct tep_handle *pevent,const char *comm,struct tep_cmdline *next) {struct cmdline_list *cmdlist = (struct cmdline_list *)next;
@@ -5358,7 +5358,7 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *newhile (cmdlist &&strcmp (cmdlist->comm, comm) !=0 ) cmdlist = cmdlist->next; -return (struct cmdline *)cmdlist; +return (struct tep_cmdline *)cmdlist; }/**
@@ -5374,10 +5374,10 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne* next pid. * Also, it does a linear seach, so it may be slow. */ -struct cmdline *tep_data_pid_from_comm (struct tep_handle *pevent,const char *comm, -struct cmdline *next) +struct tep_cmdline *tep_data_pid_from_comm (struct tep_handle *pevent,const char *comm, +struct tep_cmdline *next) { -struct cmdline *cmdline; +struct tep_cmdline *cmdline;/* * If the cmdlines have not been converted yet, then use
@@ -5416,7 +5416,7 @@ struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *co* Returns the pid for a give cmdline. If @cmdline is NULL, then * -1 is returned. */ -int tep_cmdline_pid (struct tep_handle *pevent,struct cmdline *cmdline) +int tep_cmdline_pid (struct tep_handle *pevent,struct tep_cmdline *cmdline) {struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline;
tools/lib/traceevent/event-parse.h +4 -4
@@ -526,10 +526,10 @@ int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);int tep_data_preempt_count (struct tep_handle *pevent,struct tep_record *rec);int tep_data_flags (struct tep_handle *pevent,struct tep_record *rec);const char *tep_data_comm_from_pid (struct tep_handle *pevent,int pid); -struct cmdline ; -struct cmdline *tep_data_pid_from_comm (struct tep_handle *pevent,const char *comm, -struct cmdline *next); -int tep_cmdline_pid (struct tep_handle *pevent,struct cmdline *cmdline); +struct tep_cmdline ; +struct tep_cmdline *tep_data_pid_from_comm (struct tep_handle *pevent,const char *comm, +struct tep_cmdline *next); +int tep_cmdline_pid (struct tep_handle *pevent,struct tep_cmdline *cmdline);void tep_print_field (struct trace_seq *s,void *data,struct tep_format_field *field);
Signature · 1 line
2.17.2
tools/lib/traceevent/event-parse.c int tep_pid_is_registered(struct tep_handle *pevent, int pid) · line 257
Quoted 12 lines · On Mon, 19 Nov 2018 12:53:08 +0000 Tzvetomir Stoyanov <[email protected]>…
tools/lib/traceevent/event-parse.c +3
-3@@ -250,9 +250,9 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid)static int add_new_comm (struct tep_handle *pevent,const char *comm,int pid,bool override) { -struct cmdline *cmdlines = pevent->cmdlines; -struct cmdline *cmdline; -struct cmdline key; +struct tep_cmdline *cmdlines = pevent->cmdlines; +struct tep_cmdline *cmdline; +struct tep_cmdline key;char *new_comm;
Hi Tzvetomir,
This part failed for me, and I'm curious to know why. The code I have, has the variable cmdline as "const struct cmdline", but the patch does not. Was this added to a different change?
Thanks!
-- Steve