diff mbox series

[v2,1/2] libtracefs: Remove tracefs_find_tracing_dir() API

Message ID 20201221072921.210230-2-tz.stoyanov@gmail.com (mailing list archive)
State Accepted
Commit 9051159860a4853addc8fdaad1301ec0430e8bdb
Headers show
Series Consolidate APIs to locate tracefs mount point. | expand

Commit Message

Tzvetomir Stoyanov (VMware) Dec. 21, 2020, 7:29 a.m. UTC
There are two APIs to get the tracefs mount point:
tracefs_get_tracing_dir() and tracefs_find_tracing_dir().
The only difference between them is that the first returns
a static cashed string and the second a newly allocated string.
In order not to confused the users with too many APIs that do
the same, the tracefs_find_tracing_dir() is removed as an API,
renamed to trace_find_tracing_dir() and is used only as library
internal function.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 include/tracefs-local.h | 2 ++
 include/tracefs.h       | 3 ---
 src/tracefs-instance.c  | 2 +-
 src/tracefs-utils.c     | 8 ++++----
 utest/tracefs-utest.c   | 9 ---------
 5 files changed, 7 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/include/tracefs-local.h b/include/tracefs-local.h
index bdbf89e..3a7ec32 100644
--- a/include/tracefs-local.h
+++ b/include/tracefs-local.h
@@ -10,8 +10,10 @@ 
 
 /* Can be overridden */
 void warning(const char *fmt, ...);
+
 int str_read_file(const char *file, char **buffer);
 char *trace_append_file(const char *dir, const char *name);
+char *trace_find_tracing_dir(void);
 
 #ifndef ACCESSPERMS
 #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
diff --git a/include/tracefs.h b/include/tracefs.h
index 5cbe898..ae4ffa0 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -15,9 +15,6 @@  void tracefs_put_tracing_file(char *name);
 /* tracefs_get_tracing_dir must *not* be freed */
 const char *tracefs_get_tracing_dir(void);
 
-/* tracefs_find_tracing_dir must be freed */
-char *tracefs_find_tracing_dir(void);
-
 /* ftrace instances */
 struct tracefs_instance;
 
diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c
index e9e24ef..bf3de7c 100644
--- a/src/tracefs-instance.c
+++ b/src/tracefs-instance.c
@@ -210,7 +210,7 @@  char *tracefs_instance_get_dir(struct tracefs_instance *instance)
 		path = tracefs_get_tracing_file(buf);
 		free(buf);
 	} else
-		path = tracefs_find_tracing_dir();
+		path = trace_find_tracing_dir();
 
 	return path;
 }
diff --git a/src/tracefs-utils.c b/src/tracefs-utils.c
index 326b455..d9850d9 100644
--- a/src/tracefs-utils.c
+++ b/src/tracefs-utils.c
@@ -60,12 +60,12 @@  static int mount_debugfs(void)
 }
 
 /**
- * tracefs_find_tracing_dir - Find tracing directory
+ * trace_find_tracing_dir - Find tracing directory
  *
  * Returns string containing the full path to the system's tracing directory.
  * The string must be freed by free()
  */
-char *tracefs_find_tracing_dir(void)
+__hidden char *trace_find_tracing_dir(void)
 {
 	char *debug_str = NULL;
 	char fspath[PATH_MAX+1];
@@ -143,7 +143,7 @@  const char *tracefs_get_tracing_dir(void)
 	if (tracing_dir)
 		return tracing_dir;
 
-	tracing_dir = tracefs_find_tracing_dir();
+	tracing_dir = trace_find_tracing_dir();
 	return tracing_dir;
 }
 
@@ -166,7 +166,7 @@  char *tracefs_get_tracing_file(const char *name)
 		return NULL;
 
 	if (!tracing) {
-		tracing = tracefs_find_tracing_dir();
+		tracing = trace_find_tracing_dir();
 		if (!tracing)
 			return NULL;
 	}
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 941b9cf..965f1ec 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -162,21 +162,12 @@  static void test_trace_file(void)
 	const char *tdir;
 	struct stat st;
 	char *file;
-	char *dir;
-
-	dir = tracefs_find_tracing_dir();
-	CU_TEST(dir != NULL);
-	CU_TEST(stat(dir, &st) == 0);
-	CU_TEST(S_ISDIR(st.st_mode));
 
 	tdir  = tracefs_get_tracing_dir();
 	CU_TEST(tdir != NULL);
 	CU_TEST(stat(tdir, &st) == 0);
 	CU_TEST(S_ISDIR(st.st_mode));
 
-	CU_TEST(strcmp(dir, tdir) == 0);
-	free(dir);
-
 	file = tracefs_get_tracing_file(NULL);
 	CU_TEST(file == NULL);
 	file = tracefs_get_tracing_file(tmp);