@@ -42,7 +42,7 @@ static inline pthread_mutex_t *trace_get_lock(struct tracefs_instance *instance)
/* Can be overridden */
void tracefs_warning(const char *fmt, ...);
-int str_read_file(const char *file, char **buffer);
+int str_read_file(const char *file, char **buffer, bool warn);
char *trace_append_file(const char *dir, const char *name);
char *trace_find_tracing_dir(void);
@@ -485,7 +485,7 @@ char **tracefs_tracers(const char *tracing_dir)
if (ret < 0)
goto out_free;
- len = str_read_file(available_tracers, &buf);
+ len = str_read_file(available_tracers, &buf, true);
if (len <= 0)
goto out_free;
@@ -545,7 +545,7 @@ static int load_events(struct tep_handle *tep,
if (ret < 0)
goto next_event;
- len = str_read_file(format, &buf);
+ len = str_read_file(format, &buf, true);
if (len <= 0)
goto next_event;
@@ -575,7 +575,7 @@ static int read_header(struct tep_handle *tep, const char *tracing_dir)
if (ret < 0)
goto out;
- len = str_read_file(header, &buf);
+ len = str_read_file(header, &buf, true);
if (len <= 0)
goto out;
@@ -400,7 +400,7 @@ char *tracefs_instance_file_read(struct tracefs_instance *instance,
if (!path)
return NULL;
- size = str_read_file(path, &buf);
+ size = str_read_file(path, &buf, true);
tracefs_put_tracing_file(path);
if (buf && psize)
@@ -196,7 +196,7 @@ void tracefs_put_tracing_file(char *name)
free(name);
}
-__hidden int str_read_file(const char *file, char **buffer)
+__hidden int str_read_file(const char *file, char **buffer, bool warn)
{
char stbuf[BUFSIZ];
char *buf = NULL;
@@ -207,7 +207,8 @@ __hidden int str_read_file(const char *file, char **buffer)
fd = open(file, O_RDONLY);
if (fd < 0) {
- tracefs_warning("File %s not found", file);
+ if (warn)
+ tracefs_warning("File %s not found", file);
return -1;
}
@@ -217,7 +218,8 @@ __hidden int str_read_file(const char *file, char **buffer)
continue;
nbuf = realloc(buf, size+r+1);
if (!nbuf) {
- tracefs_warning("Failed to allocate file buffer");
+ if (warn)
+ tracefs_warning("Failed to allocate file buffer");
size = -1;
break;
}