trace-cmd libtraceevent: Fix build warning on 32-bit arches
PATCH 1/1 trace-cmd libtraceevent: Fix build warning on 32-bit arches
Fixed a compilation warning for casting to pointer from integer of different size on 32-bit platforms.
--- lib/traceevent/event-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/traceevent/event-parse.c +1 -1
@@ -5305,7 +5305,7 @@ static int print_arg_pointer(struct trace_seq *s, const char *format, int plen,default : ret =0 ; val =eval_num_arg (data, size, event, arg); -trace_seq_printf (s,"%p" , (void *)val); +trace_seq_printf (s,"%p" , (void *)(intptr_t )val);break ; }
Signature · 1 line
2.26.2
PATCH 1/1 tools lib traceevent: Hide non API functions
There are internal library functions, which are not decalred as a static. They are used inside the library from different files. Hide them from the library users, as they are not part of the API.
These functions are made hidden and are renamed without the prefix "tep_":
tep_free_plugin_paths
tep_peek_char
tep_buffer_init
tep_get_input_buf_ptr
tep_get_input_buf
tep_read_token
tep_free_token
tep_free_event
tep_free_format_field
tep_free_plugin_paths
--- tools/lib/traceevent/event-parse-api.c | 8 +-- tools/lib/traceevent/event-parse-local.h | 24 +++++-- tools/lib/traceevent/event-parse.c | 88 ++++++------------------ tools/lib/traceevent/event-parse.h | 8 --- tools/lib/traceevent/event-plugin.c | 2 +- tools/lib/traceevent/parse-filter.c | 23 +++---- 6 files changed, 52 insertions(+), 101 deletions(-)
tools/lib/traceevent/event-parse-api.c +4 -4
@@ -92,7 +92,7 @@ bool tep_test_flag(struct tep_handle *tep, enum tep_flag flag)return false; } -unsigned short tep_data2host2 (struct tep_handle *tep,unsigned short data) +__hidden unsigned short _data2host2 (struct tep_handle *tep,unsigned short data) {unsigned short swap;
@@ -105,7 +105,7 @@ unsigned short tep_data2host2(struct tep_handle *tep, unsigned short data)return swap; } -unsigned int tep_data2host4 (struct tep_handle *tep,unsigned int data) +__hidden unsigned int _data2host4(struct tep_handle *tep, unsigned int data) {unsigned int swap;
@@ -120,8 +120,8 @@ unsigned int tep_data2host4(struct tep_handle *tep, unsigned int data)return swap; } -unsigned long long -tep_data2host8 (struct tep_handle *tep,unsigned long long data) +__hidden unsigned long long +_data2host8 (struct tep_handle *tep,unsigned long long data) {unsigned long long swap;
tools/lib/traceevent/event-parse-local.h +17 -7
@@ -15,6 +15,8 @@ struct event_handler;struct func_resolver ;struct tep_plugins_dir ; +#define __hidden __attribute__((visibility ("hidden"))) +struct tep_handle {int ref_count;
@@ -102,12 +104,20 @@ struct tep_print_parse {struct tep_print_arg *len_as_arg; }; -void tep_free_event (struct tep_event *event); -void tep_free_format_field (struct tep_format_field *field); -void tep_free_plugin_paths (struct tep_handle *tep); - -unsigned short tep_data2host2 (struct tep_handle *tep,unsigned short data); -unsigned int tep_data2host4 (struct tep_handle *tep,unsigned int data); -unsigned long long tep_data2host8 (struct tep_handle *tep,unsigned long long data); +void free_tep_event (struct tep_event *event); +void free_tep_format_field (struct tep_format_field *field); +void free_tep_plugin_paths (struct tep_handle *tep); + +unsigned short _data2host2 (struct tep_handle *tep,unsigned short data); +unsigned int _data2host4 (struct tep_handle *tep,unsigned int data); +unsigned long long _data2host8 (struct tep_handle *tep,unsigned long long data); + +/* access to the internal parser */ +int __peek_char (void ); +void init_input_buf (const char *buf,unsigned long long size); +unsigned long long get_input_buf_ptr (void ); +const char *get_input_buf (void ); +enum tep_event_type read_token (char **tok); +void free_token (char *tok);#endif /* _PARSE_EVENTS_INT_H */
tools/lib/traceevent/event-parse.c +21 -67
208 lines not on this page · raw message
tools/lib/traceevent/event-parse.h +0 -8
@@ -578,14 +578,6 @@ void tep_ref(struct tep_handle *tep);void tep_unref (struct tep_handle *tep);int tep_get_ref (struct tep_handle *tep); -/* access to the internal parser */ -void tep_buffer_init (const char *buf,unsigned long long size); -enum tep_event_type tep_read_token (char **tok); -void tep_free_token (char *token); -int tep_peek_char (void ); -const char *tep_get_input_buf (void ); -unsigned long long tep_get_input_buf_ptr (void ); -/* for debugging */ void tep_print_funcs (struct tep_handle *tep);void tep_print_printk (struct tep_handle *tep);
tools/lib/traceevent/event-plugin.c +1 -1
@@ -676,7 +676,7 @@ int tep_add_plugin_path(struct tep_handle *tep, char *path,return 0 ; } -void tep_free_plugin_paths (struct tep_handle *tep) +__hidden void free_tep_plugin_paths(struct tep_handle *tep) {struct tep_plugins_dir *dir;
tools/lib/traceevent/parse-filter.c +9 -14
@@ -38,8 +38,8 @@ static void show_error(char *error_buf, const char *fmt, ...)int len;int i; - input =tep_get_input_buf (); - index =tep_get_input_buf_ptr (); + input =get_input_buf (); + index =get_input_buf_ptr (); len = input ?strlen (input) :0 ;if (len) {
@@ -57,25 +57,20 @@ static void show_error(char *error_buf, const char *fmt, ...)va_end (ap); } -static void free_token (char *token) -{ -tep_free_token (token); -} - -static enum tep_event_type read_token (char **tok) +static enum tep_event_type filter_read_token (char **tok) {enum tep_event_type type;char *token =NULL ;do {free_token (token); - type =tep_read_token (&token); + type =read_token (&token); }while (type ==TEP_EVENT_NEWLINE || type ==TEP_EVENT_SPACE );/* If token is = or ! check to see if the next char is ~ */ if (token && (strcmp (token,"=" ) ==0 ||strcmp (token,"!" ) ==0 ) && -tep_peek_char () =='~' ) { +__peek_char () =='~' ) {/* append it */ *tok =malloc (3 );if (*tok ==NULL ) {
@@ -85,7 +80,7 @@ static enum tep_event_type read_token(char **tok)sprintf (*tok,"%c%c" , *token,'~' );free_token (token);/* Now remove the '~' from the buffer */ -tep_read_token (&token); +read_token (&token);free_token (token); }else *tok = token;
@@ -959,7 +954,7 @@ process_filter(struct tep_event *event, struct tep_filter_arg **parg, do { free(token); - type = read_token(&token); + type = filter_read_token(&token); switch (type) { case TEP_EVENT_SQUOTE: case TEP_EVENT_DQUOTE:
@@ -1185,7 +1180,7 @@ process_event(struct tep_event *event, const char *filter_str, {int ret; -tep_buffer_init (filter_str,strlen (filter_str)); +init_input_buf (filter_str,strlen (filter_str)); ret =process_filter (event, parg, error_str,0 );if (ret <0 )
@@ -1243,7 +1238,7 @@ filter_event(struct tep_event_filter *filter, struct tep_event *event,static void filter_init_error_buf (struct tep_event_filter *filter) {/* clear buffer to reset show error */ -tep_buffer_init ("" ,0 ); +init_input_buf ("" ,0 ); filter->error_buffer[0 ] ='\0' ; }
Signature · 1 line
2.26.2
Re: [PATCH] tools lib traceevent: Hide non API functions
Quoted 5 lines · On Thu, 24 Sep 2020 10:06:09 +0300 "Tzvetomir Stoyanov (VMware)"…
There are internal library functions, which are not decalred as a static. They are used inside the library from different files. Hide them from the library users, as they are not part of the API.
These functions are made hidden and are renamed without the prefix "tep_":
tep_free_plugin_paths
Quoted 8 lines
tep_peek_char
tep_buffer_init
tep_get_input_buf_ptr
tep_get_input_buf
tep_read_token
tep_free_token
tep_free_event
tep_free_format_field
You have tep_free_plugin_paths twice.
Quoted 27 lines
tep_free_plugin_pathsReported-by Ben Hutchings <[email protected]>Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>--- tools/lib/traceevent/event-parse-api.c | 8 +-- tools/lib/traceevent/event-parse-local.h | 24 +++++-- tools/lib/traceevent/event-parse.c | 88 ++++++------------------ tools/lib/traceevent/event-parse.h | 8 --- tools/lib/traceevent/event-plugin.c | 2 +- tools/lib/traceevent/parse-filter.c | 23 +++---- 6 files changed, 52 insertions(+), 101 deletions(-)tools/lib/traceevent/event-parse-api.c +1
-1@@ -92,7 +92,7 @@ bool tep_test_flag(struct tep_handle *tep, enum tep_flag flag)return false; } -unsigned short tep_data2host2 (struct tep_handle *tep,unsigned short data) +__hidden unsigned short _data2host2 (struct tep_handle *tep,unsigned short data) {unsigned short swap;
tools/lib/traceevent/event-parse-api.c unsigned short tep_data2host2(struct tep_handle *tep, unsigned short data) · line 108
Quoted 5 lines
tools/lib/traceevent/event-parse-api.c +1
-1@@ -105,7 +105,7 @@ unsigned short tep_data2host2(struct tep_handle *tep, unsigned short data)return swap; } -unsigned int tep_data2host4 (struct tep_handle *tep,unsigned int data) +__hidden unsigned int _data2host4(struct tep_handle *tep, unsigned int data)
As these are hidden, we don't need the leading underscore. Thus data2host2 and data2host4, etc, is fine.
Quoted 38 lines
tools/lib/traceevent/event-parse-api.c +2
-2{unsigned int swap;@@ -120,8 +120,8 @@ unsigned int tep_data2host4(struct tep_handle *tep, unsigned int data)return swap; } -unsigned long long -tep_data2host8 (struct tep_handle *tep,unsigned long long data) +__hidden unsigned long long +_data2host8 (struct tep_handle *tep,unsigned long long data) {unsigned long long swap;tools/lib/traceevent/event-parse-local.h +2
-7@@ -15,6 +15,8 @@ struct event_handler;struct func_resolver ;struct tep_plugins_dir ; +#define __hidden __attribute__((visibility ("hidden"))) +struct tep_handle {int ref_count;@@ -102,12 +104,20 @@ struct tep_print_parse {struct tep_print_arg *len_as_arg; }; -void tep_free_event (struct tep_event *event); -void tep_free_format_field (struct tep_format_field *field); -void tep_free_plugin_paths (struct tep_handle *tep); - -unsigned short tep_data2host2 (struct tep_handle *tep,unsigned short data); -unsigned int tep_data2host4 (struct tep_handle *tep,unsigned int data); -unsigned long long tep_data2host8 (struct tep_handle *tep,unsigned long long data);
tools/lib/traceevent/event-parse-local.h struct tep_print_parse { · line 116
Quoted 10 lines
tools/lib/traceevent/event-parse-local.h +10
-0+void free_tep_event (struct tep_event *event); +void free_tep_format_field (struct tep_format_field *field); +void free_tep_plugin_paths (struct tep_handle *tep); + +unsigned short _data2host2 (struct tep_handle *tep,unsigned short data); +unsigned int _data2host4 (struct tep_handle *tep,unsigned int data); +unsigned long long _data2host8 (struct tep_handle *tep,unsigned long long data); + +/* access to the internal parser */ +int __peek_char (void );
Same for __peek_char(). We can call it peek_char().
Other than that, I think this looks good.
When sending the next version, I would send it to Arnaldo directly and Cc this list, LKML, and myself. Then I'll just ack it for Arnaldo to take it directly from you.
Add v2 in the subject '[PATCH v2]' and state the differences of v1 after the '---' of your signed off by. You could also add,
V1 found here: https://lore.kernel.org/r/[email protected]
so that Arnaldo knows where to find v1, as I don't think he's on this list.
Thanks!
-- Steve