All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] trace-cmd: Some more minor updates
@ 2020-04-14  1:44 Steven Rostedt
  2020-04-14  1:44 ` [PATCH 1/2] trace-cmd: Use "exists" instead of "exist" Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-04-14  1:44 UTC (permalink / raw)
  To: linux-trace-devel

These are minor changes and instead of having Tzvetomir resend the patches
with the updates, I just made the changes.

First patch is to change the grammar of the function names that have
"file_exist" and "dir_exist" to "file_exists" and "dir_exists" respectively,
as they sound better for a native English speaker.

The second is just a micro-optimization of the return code of
check_file_exists().

Steven Rostedt (VMware) (2):
      trace-cmd: Use "exists" instead of "exist"
      trace-cmd: Optimize check_file_exists()

----
 include/tracefs/tracefs.h      |  4 ++--
 lib/tracefs/tracefs-instance.c | 21 ++++++++-------------
 tracecmd/trace-record.c        |  2 +-
 utest/tracefs-utest.c          | 28 ++++++++++++++--------------
 4 files changed, 25 insertions(+), 30 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] trace-cmd: Use "exists" instead of "exist"
  2020-04-14  1:44 [PATCH 0/2] trace-cmd: Some more minor updates Steven Rostedt
@ 2020-04-14  1:44 ` Steven Rostedt
  2020-04-14  1:44 ` [PATCH 2/2] trace-cmd: Optimize check_file_exists() Steven Rostedt
  2020-04-14 14:16 ` [PATCH 0/2] trace-cmd: Some more minor updates Tzvetomir Stoyanov
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-04-14  1:44 UTC (permalink / raw)
  To: linux-trace-devel

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

As a native English speaker, I find that the words "file_exists" and
"dir_exists" sounds better to the ear than "file_exist" and "dir_exist".
As "exist" is for the plural, and "exists" is for the singular.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/tracefs/tracefs.h      |  4 ++--
 lib/tracefs/tracefs-instance.c | 14 +++++++-------
 tracecmd/trace-record.c        |  2 +-
 utest/tracefs-utest.c          | 28 ++++++++++++++--------------
 4 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/include/tracefs/tracefs.h b/include/tracefs/tracefs.h
index bc8bebcb05a0..8ee7ba6e9d7a 100644
--- a/include/tracefs/tracefs.h
+++ b/include/tracefs/tracefs.h
@@ -33,8 +33,8 @@ int tracefs_instance_file_write(struct tracefs_instance *instance,
 char *tracefs_instance_file_read(struct tracefs_instance *instance,
 				 char *file, int *psize);
 
-bool tracefs_file_exist(struct tracefs_instance *instance, char *name);
-bool tracefs_dir_exist(struct tracefs_instance *instance, char *name);
+bool tracefs_file_exists(struct tracefs_instance *instance, char *name);
+bool tracefs_dir_exists(struct tracefs_instance *instance, char *name);
 
 /* events */
 void tracefs_list_free(char **list);
diff --git a/lib/tracefs/tracefs-instance.c b/lib/tracefs/tracefs-instance.c
index 67123e7c14bf..a8729406b9fc 100644
--- a/lib/tracefs/tracefs-instance.c
+++ b/lib/tracefs/tracefs-instance.c
@@ -248,7 +248,7 @@ char *tracefs_instance_file_read(struct tracefs_instance *instance,
 	return buf;
 }
 
-static bool check_file_exist(struct tracefs_instance *instance,
+static bool check_file_exists(struct tracefs_instance *instance,
 			     char *name, bool dir)
 {
 	char file[PATH_MAX];
@@ -272,25 +272,25 @@ static bool check_file_exist(struct tracefs_instance *instance,
 }
 
 /**
- * tracefs_file_exist - Check if a file with given name exists in given instance
+ * tracefs_file_exists - Check if a file with given name exists in given instance
  * @instance: ftrace instance, can be NULL for the top instance
  * @name: name of the file
  *
  * Returns true if the file exists, false otherwise
  */
-bool tracefs_file_exist(struct tracefs_instance *instance, char *name)
+bool tracefs_file_exists(struct tracefs_instance *instance, char *name)
 {
-	return check_file_exist(instance, name, false);
+	return check_file_exists(instance, name, false);
 }
 
 /**
- * tracefs_dir_exist - Check if a directory with given name exists in given instance
+ * tracefs_dir_exists - Check if a directory with given name exists in given instance
  * @instance: ftrace instance, can be NULL for the top instance
  * @name: name of the directory
  *
  * Returns true if the directory exists, false otherwise
  */
-bool tracefs_dir_exist(struct tracefs_instance *instance, char *name)
+bool tracefs_dir_exists(struct tracefs_instance *instance, char *name)
 {
-	return check_file_exist(instance, name, true);
+	return check_file_exists(instance, name, true);
 }
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 955ab75d1b47..d89b32d3e2dd 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -4791,7 +4791,7 @@ static void clear_instance_error_log(struct buffer_instance *instance)
 {
 	char *file;
 
-	if (!tracefs_file_exist(instance->tracefs, "error_log"))
+	if (!tracefs_file_exists(instance->tracefs, "error_log"))
 		return;
 
 	file = tracefs_instance_get_file(instance->tracefs, "error_log");
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 3f57ecad3962..1c1465767ecc 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -252,20 +252,20 @@ static void test_instance_file(void)
 	tracefs_put_tracing_file(inst_file);
 	free(fname);
 
-	CU_TEST(tracefs_file_exist(NULL, (char *)name) == false);
-	CU_TEST(tracefs_dir_exist(NULL, (char *)name) == false);
-	CU_TEST(tracefs_file_exist(instance, (char *)name) == false);
-	CU_TEST(tracefs_dir_exist(instance, (char *)name) == false);
-
-	CU_TEST(tracefs_file_exist(NULL, CUR_TRACER) == true);
-	CU_TEST(tracefs_dir_exist(NULL, CUR_TRACER) == false);
-	CU_TEST(tracefs_file_exist(instance, CUR_TRACER) == true);
-	CU_TEST(tracefs_dir_exist(instance, CUR_TRACER) == false);
-
-	CU_TEST(tracefs_file_exist(NULL, PER_CPU) == false);
-	CU_TEST(tracefs_dir_exist(NULL, PER_CPU) == true);
-	CU_TEST(tracefs_file_exist(instance, PER_CPU) == false);
-	CU_TEST(tracefs_dir_exist(instance, PER_CPU) == true);
+	CU_TEST(tracefs_file_exists(NULL, (char *)name) == false);
+	CU_TEST(tracefs_dir_exists(NULL, (char *)name) == false);
+	CU_TEST(tracefs_file_exists(instance, (char *)name) == false);
+	CU_TEST(tracefs_dir_exists(instance, (char *)name) == false);
+
+	CU_TEST(tracefs_file_exists(NULL, CUR_TRACER) == true);
+	CU_TEST(tracefs_dir_exists(NULL, CUR_TRACER) == false);
+	CU_TEST(tracefs_file_exists(instance, CUR_TRACER) == true);
+	CU_TEST(tracefs_dir_exists(instance, CUR_TRACER) == false);
+
+	CU_TEST(tracefs_file_exists(NULL, PER_CPU) == false);
+	CU_TEST(tracefs_dir_exists(NULL, PER_CPU) == true);
+	CU_TEST(tracefs_file_exists(instance, PER_CPU) == false);
+	CU_TEST(tracefs_dir_exists(instance, PER_CPU) == true);
 
 	CU_TEST(tracefs_instance_destroy(NULL) != 0);
 	CU_TEST(tracefs_instance_destroy(instance) == 0);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] trace-cmd: Optimize check_file_exists()
  2020-04-14  1:44 [PATCH 0/2] trace-cmd: Some more minor updates Steven Rostedt
  2020-04-14  1:44 ` [PATCH 1/2] trace-cmd: Use "exists" instead of "exist" Steven Rostedt
@ 2020-04-14  1:44 ` Steven Rostedt
  2020-04-14 14:16 ` [PATCH 0/2] trace-cmd: Some more minor updates Tzvetomir Stoyanov
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-04-14  1:44 UTC (permalink / raw)
  To: linux-trace-devel

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

       if (dir && !S_ISDIR(st.st_mode))
               return false;
       if (!dir && S_ISDIR(st.st_mode))
               return false;
       return true;

Is the same as:

       return !dir == !S_ISDIR(st.st_mode);

Micro-optimize the logic!

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/tracefs/tracefs-instance.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lib/tracefs/tracefs-instance.c b/lib/tracefs/tracefs-instance.c
index a8729406b9fc..012a867038b7 100644
--- a/lib/tracefs/tracefs-instance.c
+++ b/lib/tracefs/tracefs-instance.c
@@ -263,12 +263,7 @@ static bool check_file_exists(struct tracefs_instance *instance,
 	if (ret < 0)
 		return false;
 
-	if (dir && !S_ISDIR(st.st_mode))
-		return false;
-	if (!dir && S_ISDIR(st.st_mode))
-		return false;
-
-	return true;
+	return !dir == !S_ISDIR(st.st_mode);
 }
 
 /**
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] trace-cmd: Some more minor updates
  2020-04-14  1:44 [PATCH 0/2] trace-cmd: Some more minor updates Steven Rostedt
  2020-04-14  1:44 ` [PATCH 1/2] trace-cmd: Use "exists" instead of "exist" Steven Rostedt
  2020-04-14  1:44 ` [PATCH 2/2] trace-cmd: Optimize check_file_exists() Steven Rostedt
@ 2020-04-14 14:16 ` Tzvetomir Stoyanov
  2 siblings, 0 replies; 4+ messages in thread
From: Tzvetomir Stoyanov @ 2020-04-14 14:16 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel

On Tue, Apr 14, 2020 at 4:44 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> These are minor changes and instead of having Tzvetomir resend the patches
> with the updates, I just made the changes.
>
> First patch is to change the grammar of the function names that have
> "file_exist" and "dir_exist" to "file_exists" and "dir_exists" respectively,
> as they sound better for a native English speaker.
>
> The second is just a micro-optimization of the return code of
> check_file_exists().
>
> Steven Rostedt (VMware) (2):
>       trace-cmd: Use "exists" instead of "exist"
>       trace-cmd: Optimize check_file_exists()
>

Looks good, thanks Steven!

Reviewed-by: Tzvetomir (VMware)  Stoyanov <tz.stoyanov@gmail.com>
> ----
>  include/tracefs/tracefs.h      |  4 ++--
>  lib/tracefs/tracefs-instance.c | 21 ++++++++-------------
>  tracecmd/trace-record.c        |  2 +-
>  utest/tracefs-utest.c          | 28 ++++++++++++++--------------
>  4 files changed, 25 insertions(+), 30 deletions(-)



-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-14 14:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14  1:44 [PATCH 0/2] trace-cmd: Some more minor updates Steven Rostedt
2020-04-14  1:44 ` [PATCH 1/2] trace-cmd: Use "exists" instead of "exist" Steven Rostedt
2020-04-14  1:44 ` [PATCH 2/2] trace-cmd: Optimize check_file_exists() Steven Rostedt
2020-04-14 14:16 ` [PATCH 0/2] trace-cmd: Some more minor updates Tzvetomir Stoyanov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.