diff mbox series

libtracefs: Rename tracefs_event_append/verify_filter() functions

Message ID 20211129123157.0ce043c3@gandalf.local.home (mailing list archive)
State Accepted
Commit b53c6487be6aab7dd626c8243514c0447b54c296
Headers show
Series libtracefs: Rename tracefs_event_append/verify_filter() functions | expand

Commit Message

Steven Rostedt Nov. 29, 2021, 5:31 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The function names:

  tracefs_event_append_filter()
  tracefs_event_verify_filter()

Are confusing, as they do not actually affect the tep_event. What they do
is to create a filter string. Rename them to a more appropriate:

  tracefs_filter_string_append()
  tracefs_filter_string_verify()

We need to keep around the old names as they have been in a tagged
release. But move them to deprecated, and have them call the appropriate
names. Also remove the old name from the man pages.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Documentation/libtracefs-filter.txt | 18 ++++++++---------
 include/tracefs.h                   | 10 ++++++++++
 src/tracefs-filter.c                | 31 +++++++++++++++++++++--------
 3 files changed, 42 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/Documentation/libtracefs-filter.txt b/Documentation/libtracefs-filter.txt
index 14fb292..23a2abf 100644
--- a/Documentation/libtracefs-filter.txt
+++ b/Documentation/libtracefs-filter.txt
@@ -3,7 +3,7 @@  libtracefs(3)
 
 NAME
 ----
-tracefs_event_append_filter, tracefs_event_verify_filter - Add and verify event filters
+tracefs_filter_string_append, tracefs_filter_string_verify - Add and verify event filters
 
 SYNOPSIS
 --------
@@ -11,16 +11,16 @@  SYNOPSIS
 --
 *#include <tracefs.h>*
 
-int tracefs_event_append_filter(struct tep_event pass:[*]event, char pass:[**] filter,
+int tracefs_filter_string_append(struct tep_event pass:[*]event, char pass:[**] filter,
 				 struct tracefs_filter type, const char pass:[*]field,
 				 enum tracefs_synth_compare compare, const char pass:[*]val);
-int tracefs_event_verify_filter(struct tep_event pass:[*]event, const char pass:[*]filter, char pass:[**]err);
+int tracefs_filter_string_verify(struct tep_event pass:[*]event, const char pass:[*]filter, char pass:[**]err);
 
 --
 
 DESCRIPTION
 -----------
-*tracefs_event_append_filter*() is a way to create and verify event filters for
+*tracefs_filter_string_append*() is a way to create and verify event filters for
 a given event. It will verify that the _field_ belongs to the event and that
 the _compare_ option that is used is valid for the type of the field, as well
 as _val_. For the _type_ that is not of *TRACEFS_FILTER_COMPARE*, it will build
@@ -60,7 +60,7 @@  _field_, _compare_, and _val_ are ignored unless _type_ is equal to
 
 *TRACEFS_COMPARE_AND* - _field_ & _val_ : where _field_ is a flags field.
 
-*tracefs_event_verify_filter*() will parse _filter_ to make sure that the
+*tracefs_filter_string_verify*() will parse _filter_ to make sure that the
 fields are for the _event_, and that the syntax is correct. If there's an
 error in the syntax, and _err_ is not NULL, then it will be allocated with an
 error message stating what was found wrong with the filter. _err_ must be freed
@@ -68,9 +68,9 @@  with *free*().
 
 RETURN VALUE
 ------------
-*tracefs_event_append_filter*() returns 0 on success and -1 on error.
+*tracefs_filter_string_append*() returns 0 on success and -1 on error.
 
-*tracefs_event_verify_filter*() returns 0 on success and -1 on error. if there
+*tracefs_filter_string_verify*() returns 0 on success and -1 on error. if there
 is an error, and _errno_ is not *ENOMEM*, then _err_ is allocated and will
 contain a string describing what was found wrong with _filter_. _err_ must be
 freed with *free*().
@@ -128,7 +128,7 @@  int main (int argc, char **argv)
 		exit(-1);
 	}
 
-	if (tracefs_event_verify_filter(event, filter, &err) < 0) {
+	if (tracefs_filter_string_verify(event, filter, &err) < 0) {
 		perror("tracecfs_event_verify_filter");
 		if (err)
 			fprintf(stderr, "%s", err);
@@ -260,7 +260,7 @@  int main (int argc, char **argv)
 			val[n] = '\0';
 			break;
 		}
-		n = tracefs_event_append_filter(event, &new_filter, type,
+		n = tracefs_filter_string_append(event, &new_filter, type,
 						field, compare, val);
 		if (n < 0) {
 			fprintf(stderr, "Failed making new filter:\n'%s'\n",
diff --git a/include/tracefs.h b/include/tracefs.h
index 8b8b554..c9ebaa6 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -467,10 +467,20 @@  enum tracefs_synth_calc {
 	TRACEFS_SYNTH_ADD,
 };
 
+int tracefs_filter_string_append(struct tep_event *event, char **filter,
+				 enum tracefs_filter type,
+				 const char *field, enum tracefs_compare compare,
+				 const char *val);
+int tracefs_filter_string_verify(struct tep_event *event, const char *filter,
+				 char **err);
+
+/** Deprecated do not use: Instead use tracefs_filter_string_append() **/
 int tracefs_event_append_filter(struct tep_event *event, char **filter,
 				enum tracefs_filter type,
 				const char *field, enum tracefs_compare compare,
 				const char *val);
+
+/** Deprecated do not use: Instead use tracefs_filter_string_verify()  **/
 int tracefs_event_verify_filter(struct tep_event *event, const char *filter,
 				char **err);
 
diff --git a/src/tracefs-filter.c b/src/tracefs-filter.c
index def8f68..e65fd94 100644
--- a/src/tracefs-filter.c
+++ b/src/tracefs-filter.c
@@ -338,7 +338,7 @@  __hidden int trace_append_filter(char **filter, unsigned int *state,
 }
 
 /**
- * tracefs_event_append_filter - create or append a filter for an event
+ * tracefs_filter_string_append - create or append a filter for an event
  * @event: tep_event to create / append a filter for
  * @filter: Pointer to string to append to (pointer to NULL to create)
  * @type: The type of element to add to the filter
@@ -387,10 +387,10 @@  __hidden int trace_append_filter(char **filter, unsigned int *state,
  *
  * Returns 0 on success and -1 on failure.
  */
-int tracefs_event_append_filter(struct tep_event *event, char **filter,
-				enum tracefs_filter type,
-				const char *field, enum tracefs_compare compare,
-				const char *val)
+int tracefs_filter_string_append(struct tep_event *event, char **filter,
+				 enum tracefs_filter type,
+				 const char *field, enum tracefs_compare compare,
+				 const char *val)
 {
 	unsigned int open_parens;
 	unsigned int state = 0;
@@ -623,7 +623,7 @@  static int get_val_end(const char *filter, int i, int *end)
 }
 
 /**
- * tracefs_event_verify_filter - verify a given filter works for an event
+ * tracefs_filter_string_verify - verify a given filter works for an event
  * @event: The event to test the given filter for
  * @filter: The filter to test
  * @err: Error message for syntax errors (NULL to ignore)
@@ -634,8 +634,8 @@  static int get_val_end(const char *filter, int i, int *end)
  * errors, @err will be allocated with an error message. It must
  * be freed with free().
  */
-int tracefs_event_verify_filter(struct tep_event *event, const char *filter,
-				char **err)
+int tracefs_filter_string_verify(struct tep_event *event, const char *filter,
+				 char **err)
 {
 	enum tracefs_filter filter_type;
 	enum tracefs_compare compare;
@@ -745,3 +745,18 @@  int tracefs_event_verify_filter(struct tep_event *event, const char *filter,
 	free(str);
 	return 0;
 }
+
+/** Deprecated **/
+int tracefs_event_append_filter(struct tep_event *event, char **filter,
+				enum tracefs_filter type,
+				const char *field, enum tracefs_compare compare,
+				const char *val)
+{
+	return tracefs_filter_string_append(event, filter, type, field,
+					    compare, val);
+}
+int tracefs_event_verify_filter(struct tep_event *event, const char *filter,
+				char **err)
+{
+	return tracefs_filter_string_verify(event, filter, err);
+}