Skip to contentSkip to conversation

libtraceevent: Rename private functions to prevent static build failures

PATCH New Metin Kaya 1 participant 1 message Nov 19, 2024

lore
Share & tools
lore

Metin Kaya

author
#0 lore raw

PATCH v2 1/1 libtraceevent: Rename private functions to prevent static build failures

Building trace-cmd statically fails because of duplicated symbols for strstrip() function which is implemented both in trace-cmd and libtracefs. The __hidden attribute does not resolve these conflicts for static builds due to the lack of namespacing support in C. Refer to the associated Bugzilla page for further details.

Although strstrip() breakage is out of libtraceevent's scope for now, proactively take a preventive action to fix the underlying issue comprehensively across the libtraceevent, libtracefs, and trace-cmd packages. Follow the recommendation and prepend "tep_" prefix to all private functions (tagged with __hidden attribute). The exceptions of this renaming scheme are free_tep_format_field, free_tep_event and free_tep_plugin_paths functions which are renamed to tep_free_format_field, tep_free_event and tep_free_plugin_paths respectively.

Future __hidden functions should follow this prefixing schemed to avoid new naming conflicts.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217768

---
 src/event-parse-api.c   |   6 +-
 src/event-parse-local.h |  24 ++--
 src/event-parse.c       | 292 ++++++++++++++++++++--------------------
 src/event-plugin.c      |   2 +-
 src/parse-filter.c      |  22 +--
 5 files changed, 173 insertions(+), 173 deletions(-)
src/event-parse-api.c +3 -3
index fd03daf..8a0e976 100644
@@ -106,7 +106,7 @@ bool tep_test_flag(struct tep_handle *tep, enum tep_flag flag)
 	return false;
 }
 
-__hidden unsigned short data2host2(struct tep_handle *tep, unsigned short data)
+__hidden unsigned short tep_data2host2(struct tep_handle *tep, unsigned short data)
 {
 	unsigned short swap;
 
@@ -119,7 +119,7 @@ __hidden unsigned short data2host2(struct tep_handle *tep, unsigned short data)
 	return swap;
 }
 
-__hidden unsigned int data2host4(struct tep_handle *tep, unsigned int data)
+__hidden unsigned int tep_data2host4(struct tep_handle *tep, unsigned int data)
 {
 	unsigned int swap;
 
@@ -135,7 +135,7 @@ __hidden unsigned int data2host4(struct tep_handle *tep, unsigned int data)
 }
 
 __hidden  unsigned long long
-data2host8(struct tep_handle *tep, unsigned long long data)
+tep_data2host8(struct tep_handle *tep, unsigned long long data)
 {
 	unsigned long long swap;
 
src/event-parse-local.h +12 -12
index c6bfc61..d9e9faf 100644
@@ -108,20 +108,20 @@ struct tep_print_parse {
 	struct tep_print_arg		*len_as_arg;
 };
 
-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);
+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 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);
+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);
 
 /* access to the internal parser */
-int peek_char(struct tep_handle *tep);
-void init_input_buf(struct tep_handle *tep, const char *buf, unsigned long long size);
-unsigned long long get_input_buf_ptr(struct tep_handle *tep);
-const char *get_input_buf(struct tep_handle *tep);
-enum tep_event_type read_token(struct tep_handle *tep, char **tok);
-void free_token(char *tok);
+int tep_peek_char(struct tep_handle *tep);
+void tep_init_input_buf(struct tep_handle *tep, const char *buf, unsigned long long size);
+unsigned long long tep_get_input_buf_ptr(struct tep_handle *tep);
+const char *tep_get_input_buf(struct tep_handle *tep);
+enum tep_event_type tep_read_token(struct tep_handle *tep, char **tok);
+void tep_free_token(char *tok);
 
 #endif /* _PARSE_EVENTS_INT_H */
src/event-parse.c +146 -146

1,043 lines not on this page · raw message

src/event-plugin.c +1 -1
index c944204..323d63b 100644
@@ -678,7 +678,7 @@ int tep_add_plugin_path(struct tep_handle *tep, char *path,
 	return 0;
 }
 
-__hidden void free_tep_plugin_paths(struct tep_handle *tep)
+__hidden void tep_free_plugin_paths(struct tep_handle *tep)
 {
 	struct tep_plugins_dir *dir;
 
src/parse-filter.c +11 -11
index 75b84a0..8045b10 100644
@@ -38,8 +38,8 @@ static void show_error(struct tep_handle *tep, char *error_buf, const char *fmt,
 	int len;
 	int i;
 
-	input = get_input_buf(tep);
-	index = get_input_buf_ptr(tep);
+	input = tep_get_input_buf(tep);
+	index = tep_get_input_buf_ptr(tep);
 	len = input ? strlen(input) : 0;
 
 	if (len) {
@@ -63,25 +63,25 @@ static enum tep_event_type filter_read_token(struct tep_handle *tep, char **tok)
 	char *token = NULL;
 
 	do {
-		free_token(token);
-		type = read_token(tep, &token);
+		tep_free_token(token);
+		type = tep_read_token(tep, &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) &&
-	    peek_char(tep) == '~') {
+	    tep_peek_char(tep) == '~') {
 		/* append it */
 		*tok = malloc(3);
 		if (*tok == NULL) {
-			free_token(token);
+			tep_free_token(token);
 			return TEP_EVENT_ERROR;
 		}
 		sprintf(*tok, "%c%c", *token, '~');
-		free_token(token);
+		tep_free_token(token);
 		/* Now remove the '~' from the buffer */
-		read_token(tep, &token);
-		free_token(token);
+		tep_read_token(tep, &token);
+		tep_free_token(token);
 	} else
 		*tok = token;
 
@@ -1182,7 +1182,7 @@ process_event(struct tep_event *event, const char *filter_str,
 {
 	int ret;
 
-	init_input_buf(event->tep, filter_str, strlen(filter_str));
+	tep_init_input_buf(event->tep, filter_str, strlen(filter_str));
 
 	ret = process_filter(event, parg, error_str, 0);
 	if (ret < 0)
@@ -1240,7 +1240,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 */
-	init_input_buf(filter->tep, "", 0);
+	tep_init_input_buf(filter->tep, "", 0);
 	filter->error_buffer[0] = '\0';
 }
 

base-commit: bd47bd544c9ebc9f44bd88c2b2f2049230741058

Signature · 1 line
2.34.1