diff options
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/thread.c | 18 | ||||
-rw-r--r-- | tools/perf/util/thread.h | 1 |
2 files changed, 13 insertions, 6 deletions
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 634b7f7140d5..9e8995eaf2b6 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
@@ -36,7 +36,10 @@ int thread__set_comm(struct thread *self, const char *comm) | |||
36 | if (self->comm) | 36 | if (self->comm) |
37 | free(self->comm); | 37 | free(self->comm); |
38 | self->comm = strdup(comm); | 38 | self->comm = strdup(comm); |
39 | return self->comm ? 0 : -ENOMEM; | 39 | if (self->comm == NULL) |
40 | return -ENOMEM; | ||
41 | self->comm_set = true; | ||
42 | return 0; | ||
40 | } | 43 | } |
41 | 44 | ||
42 | int thread__comm_len(struct thread *self) | 45 | int thread__comm_len(struct thread *self) |
@@ -255,11 +258,14 @@ int thread__fork(struct thread *self, struct thread *parent) | |||
255 | { | 258 | { |
256 | int i; | 259 | int i; |
257 | 260 | ||
258 | if (self->comm) | 261 | if (parent->comm_set) { |
259 | free(self->comm); | 262 | if (self->comm) |
260 | self->comm = strdup(parent->comm); | 263 | free(self->comm); |
261 | if (!self->comm) | 264 | self->comm = strdup(parent->comm); |
262 | return -ENOMEM; | 265 | if (!self->comm) |
266 | return -ENOMEM; | ||
267 | self->comm_set = true; | ||
268 | } | ||
263 | 269 | ||
264 | for (i = 0; i < MAP__NR_TYPES; ++i) | 270 | for (i = 0; i < MAP__NR_TYPES; ++i) |
265 | if (map_groups__clone(&self->mg, &parent->mg, i) < 0) | 271 | if (map_groups__clone(&self->mg, &parent->mg, i) < 0) |
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 56f317b8a06c..0a28f39de545 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h | |||
@@ -15,6 +15,7 @@ struct thread { | |||
15 | struct map_groups mg; | 15 | struct map_groups mg; |
16 | pid_t pid; | 16 | pid_t pid; |
17 | char shortname[3]; | 17 | char shortname[3]; |
18 | bool comm_set; | ||
18 | char *comm; | 19 | char *comm; |
19 | int comm_len; | 20 | int comm_len; |
20 | }; | 21 | }; |