From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v2] libtracefs: Prefer using "const char *" arguments
Date: Thu, 25 Mar 2021 14:29:06 +0200 [thread overview]
Message-ID: <20210325122906.28109-1-y.karadz@gmail.com> (raw)
All functions should receive const string arguments, except in the
cases when the argument string itself needs to be modified.
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
include/tracefs.h | 4 ++--
src/tracefs-instance.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/tracefs.h b/include/tracefs.h
index f3eec62..05bd0ef 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -42,8 +42,8 @@ int tracefs_instance_file_open(struct tracefs_instance *instance,
int tracefs_instances_walk(int (*callback)(const char *, void *), void *context);
bool tracefs_instance_exists(const char *name);
-bool tracefs_file_exists(struct tracefs_instance *instance, char *name);
-bool tracefs_dir_exists(struct tracefs_instance *instance, char *name);
+bool tracefs_file_exists(struct tracefs_instance *instance, const char *name);
+bool tracefs_dir_exists(struct tracefs_instance *instance, const char *name);
int tracefs_trace_is_on(struct tracefs_instance *instance);
int tracefs_trace_on(struct tracefs_instance *instance);
diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c
index 0df4e13..0df313c 100644
--- a/src/tracefs-instance.c
+++ b/src/tracefs-instance.c
@@ -436,7 +436,7 @@ int tracefs_instance_file_open(struct tracefs_instance *instance,
}
static bool check_file_exists(struct tracefs_instance *instance,
- char *name, bool dir)
+ const char *name, bool dir)
{
char file[PATH_MAX];
struct stat st;
@@ -482,7 +482,7 @@ bool tracefs_instance_exists(const char *name)
*
* If a directory with the given name exists, false is returned.
*/
-bool tracefs_file_exists(struct tracefs_instance *instance, char *name)
+bool tracefs_file_exists(struct tracefs_instance *instance, const char *name)
{
return check_file_exists(instance, name, false);
}
@@ -494,7 +494,7 @@ bool tracefs_file_exists(struct tracefs_instance *instance, char *name)
*
* Returns true if the directory exists, false otherwise
*/
-bool tracefs_dir_exists(struct tracefs_instance *instance, char *name)
+bool tracefs_dir_exists(struct tracefs_instance *instance, const char *name)
{
return check_file_exists(instance, name, true);
}
--
2.27.0
reply other threads:[~2021-03-25 12:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210325122906.28109-1-y.karadz@gmail.com \
--to=y.karadz@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).