linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH v2 1/2] libtracefs: Remove tracefs_find_tracing_dir() API
Date: Mon, 21 Dec 2020 09:29:20 +0200	[thread overview]
Message-ID: <20201221072921.210230-2-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20201221072921.210230-1-tz.stoyanov@gmail.com>

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 --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);
-- 
2.28.0


  reply	other threads:[~2020-12-21  7:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21  7:29 [PATCH v2 0/2] Consolidate APIs to locate tracefs mount point Tzvetomir Stoyanov (VMware)
2020-12-21  7:29 ` Tzvetomir Stoyanov (VMware) [this message]
2020-12-21  7:29 ` [PATCH v2 2/2] libtracefs: Rename tracefs_get_tracing_dir() to tracefs_tracing_dir() Tzvetomir Stoyanov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201221072921.210230-2-tz.stoyanov@gmail.com \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).