perf trace: Move the files table resizing to outside set_pathname()
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: d7e134845d6b19288dec5582ce91d6c6052fcdad Gitweb: https://git.kernel.org/tip/d7e134845d6b19288dec5582ce91d6c6052fcdad Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Thu, 27 Dec 2018 11:05:18 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 28 Dec 2018 16:33:03 -0300
perf trace: Move the files table resizing to outside set_pathname()
So that we can have that table expanded when setting other attributes.
Cc Adrian Hunter <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Luis Cláudio Gonçalves <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-trace.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
tools/perf/builtin-trace.c +16 -6
@@ -1040,15 +1040,13 @@ void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg,static const size_t trace__entry_str_size =2048 ; -static int trace__set_fd_pathname (struct thread *thread,int fd,const char *pathname) +static struct file *thread_trace__files_entry (struct thread_trace *ttrace,int fd) { -struct thread_trace *ttrace =thread__priv (thread); -if (fd > ttrace->files.max) {struct file *nfiles =realloc (ttrace->files.table, (fd +1 ) *sizeof (struct file ));if (nfiles ==NULL ) -return -1 ; +return NULL ;if (ttrace->files.max !=-1 ) { memset(nfiles + ttrace->files.max + 1, 0,
@@ -1061,9 +1059,21 @@ static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pat ttrace->files.max = fd; } - ttrace->files.table[fd].pathname =strdup (pathname); +return ttrace->files.table + fd; +} + +static int trace__set_fd_pathname (struct thread *thread,int fd,const char *pathname) +{ +struct thread_trace *ttrace =thread__priv (thread); +struct file *file =thread_trace__files_entry (ttrace, fd); + +if (file !=NULL ) { + file->pathname =strdup (pathname); +if (file->pathname) +return 0 ; + } -return ttrace->files.table[fd].pathname !=NULL ?0 :-1 ; +return -1 ; }static int thread__read_fd_path (struct thread *thread,int fd)