diff options
| -rw-r--r-- | tools/perf/util/comm.c | 19 | ||||
| -rw-r--r-- | tools/perf/util/comm.h | 2 | ||||
| -rw-r--r-- | tools/perf/util/thread.c | 5 |
3 files changed, 15 insertions, 11 deletions
diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c index 67d1e404c0cb..f9e777629e21 100644 --- a/tools/perf/util/comm.c +++ b/tools/perf/util/comm.c | |||
| @@ -94,19 +94,20 @@ struct comm *comm__new(const char *str, u64 timestamp) | |||
| 94 | return comm; | 94 | return comm; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | void comm__override(struct comm *comm, const char *str, u64 timestamp) | 97 | int comm__override(struct comm *comm, const char *str, u64 timestamp) |
| 98 | { | 98 | { |
| 99 | struct comm_str *old = comm->comm_str; | 99 | struct comm_str *new, *old = comm->comm_str; |
| 100 | 100 | ||
| 101 | comm->comm_str = comm_str__findnew(str, &comm_str_root); | 101 | new = comm_str__findnew(str, &comm_str_root); |
| 102 | if (!comm->comm_str) { | 102 | if (!new) |
| 103 | comm->comm_str = old; | 103 | return -ENOMEM; |
| 104 | return; | ||
| 105 | } | ||
| 106 | 104 | ||
| 107 | comm->start = timestamp; | 105 | comm_str__get(new); |
| 108 | comm_str__get(comm->comm_str); | ||
| 109 | comm_str__put(old); | 106 | comm_str__put(old); |
| 107 | comm->comm_str = new; | ||
| 108 | comm->start = timestamp; | ||
| 109 | |||
| 110 | return 0; | ||
| 110 | } | 111 | } |
| 111 | 112 | ||
| 112 | void comm__free(struct comm *comm) | 113 | void comm__free(struct comm *comm) |
diff --git a/tools/perf/util/comm.h b/tools/perf/util/comm.h index 7a86e5656710..fac5bd51befc 100644 --- a/tools/perf/util/comm.h +++ b/tools/perf/util/comm.h | |||
| @@ -16,6 +16,6 @@ struct comm { | |||
| 16 | void comm__free(struct comm *comm); | 16 | void comm__free(struct comm *comm); |
| 17 | struct comm *comm__new(const char *str, u64 timestamp); | 17 | struct comm *comm__new(const char *str, u64 timestamp); |
| 18 | const char *comm__str(const struct comm *comm); | 18 | const char *comm__str(const struct comm *comm); |
| 19 | void comm__override(struct comm *comm, const char *str, u64 timestamp); | 19 | int comm__override(struct comm *comm, const char *str, u64 timestamp); |
| 20 | 20 | ||
| 21 | #endif /* __PERF_COMM_H */ | 21 | #endif /* __PERF_COMM_H */ |
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index e3948612543e..0358882c8910 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
| @@ -66,10 +66,13 @@ struct comm *thread__comm(const struct thread *thread) | |||
| 66 | int thread__set_comm(struct thread *thread, const char *str, u64 timestamp) | 66 | int thread__set_comm(struct thread *thread, const char *str, u64 timestamp) |
| 67 | { | 67 | { |
| 68 | struct comm *new, *curr = thread__comm(thread); | 68 | struct comm *new, *curr = thread__comm(thread); |
| 69 | int err; | ||
| 69 | 70 | ||
| 70 | /* Override latest entry if it had no specific time coverage */ | 71 | /* Override latest entry if it had no specific time coverage */ |
| 71 | if (!curr->start) { | 72 | if (!curr->start) { |
| 72 | comm__override(curr, str, timestamp); | 73 | err = comm__override(curr, str, timestamp); |
| 74 | if (err) | ||
| 75 | return err; | ||
| 73 | } else { | 76 | } else { |
| 74 | new = comm__new(str, timestamp); | 77 | new = comm__new(str, timestamp); |
| 75 | if (!new) | 78 | if (!new) |
