libtracefs: Prefer using "const char *" arguments
PATCH v2 1/1 libtracefs: Prefer using "const char *" arguments
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) <[email protected]>
--- include/tracefs.h | 4 ++-- src/tracefs-instance.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
include/tracefs.h +2 -2
@@ -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);
src/tracefs-instance.c +3 -3
@@ -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); }
Signature · 1 line
2.27.0