* [PATCH v3 0/4] Fill in lacking parts and Refactor several parts
@ 2017-02-01 12:34 Taeung Song
2017-02-01 12:34 ` [PATCH v3 1/4] perf tools: Only increase index if perf_evsel__new_idx() succeeds Taeung Song
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Taeung Song @ 2017-02-01 12:34 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Jiri Olsa, Namhyung Kim, Ingo Molnar,
Peter Zijlstra, Wang Nan, Taeung Song
v3:
- Split a patch in accordance with "no functional changes"
or "change logic" (Arnaldo)
- Change the title of commit message (Arnaldo)
v2:
- Check the return of perf_config() and
warn the user with config error message (Arnaldo)
- Change commit messages (Jiri)
- Add only one macro instead of two macros (Jiri)
Taeung Song (4):
perf tools: Only increase index if perf_evsel__new_idx() succeeds
perf tools: Fill in a lacking part no checking NULL after zalloc() in
parse-events.c
perf tools: Use zfree() instead of free() and assigning NULL to the
pointer
perf tools: Use zfree() to be more safe in parse-events.c
tools/perf/util/parse-events.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/4] perf tools: Only increase index if perf_evsel__new_idx() succeeds
2017-02-01 12:34 [PATCH v3 0/4] Fill in lacking parts and Refactor several parts Taeung Song
@ 2017-02-01 12:34 ` Taeung Song
2017-02-10 7:45 ` [tip:perf/core] " tip-bot for Taeung Song
2017-02-01 12:34 ` [PATCH v3 2/4] perf tools: Fill in a lacking part no checking NULL after zalloc() in parse-events.c Taeung Song
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Taeung Song @ 2017-02-01 12:34 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Jiri Olsa, Namhyung Kim, Ingo Molnar,
Peter Zijlstra, Wang Nan, Taeung Song
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/util/parse-events.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 3c876b8..5d90fe7 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -310,10 +310,11 @@ __add_event(struct list_head *list, int *idx,
event_attr_init(attr);
- evsel = perf_evsel__new_idx(attr, (*idx)++);
+ evsel = perf_evsel__new_idx(attr, *idx);
if (!evsel)
return NULL;
+ (*idx)++;
evsel->cpus = cpu_map__get(cpus);
evsel->own_cpus = cpu_map__get(cpus);
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 2/4] perf tools: Fill in a lacking part no checking NULL after zalloc() in parse-events.c
2017-02-01 12:34 [PATCH v3 0/4] Fill in lacking parts and Refactor several parts Taeung Song
2017-02-01 12:34 ` [PATCH v3 1/4] perf tools: Only increase index if perf_evsel__new_idx() succeeds Taeung Song
@ 2017-02-01 12:34 ` Taeung Song
2017-02-10 7:46 ` [tip:perf/core] perf tools: Add missing check for failure in a zalloc() call tip-bot for Taeung Song
2017-02-01 12:34 ` [PATCH v3 3/4] perf tools: Use zfree() instead of free() and assigning NULL to the pointer Taeung Song
2017-02-01 12:34 ` [PATCH v3 4/4] perf tools: Use zfree() to be more safe in parse-events.c Taeung Song
3 siblings, 1 reply; 8+ messages in thread
From: Taeung Song @ 2017-02-01 12:34 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Jiri Olsa, Namhyung Kim, Ingo Molnar,
Peter Zijlstra, Wang Nan, Taeung Song
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/util/parse-events.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5d90fe7..0c3b81a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -211,6 +211,8 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
closedir(evt_dir);
closedir(sys_dir);
path = zalloc(sizeof(*path));
+ if (!path)
+ return NULL;
path->system = malloc(MAX_EVENT_LENGTH);
if (!path->system) {
free(path);
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 3/4] perf tools: Use zfree() instead of free() and assigning NULL to the pointer
2017-02-01 12:34 [PATCH v3 0/4] Fill in lacking parts and Refactor several parts Taeung Song
2017-02-01 12:34 ` [PATCH v3 1/4] perf tools: Only increase index if perf_evsel__new_idx() succeeds Taeung Song
2017-02-01 12:34 ` [PATCH v3 2/4] perf tools: Fill in a lacking part no checking NULL after zalloc() in parse-events.c Taeung Song
@ 2017-02-01 12:34 ` Taeung Song
2017-02-10 7:46 ` [tip:perf/core] perf tools: Use zfree() instead of ad hoc equivalent tip-bot for Taeung Song
2017-02-01 12:34 ` [PATCH v3 4/4] perf tools: Use zfree() to be more safe in parse-events.c Taeung Song
3 siblings, 1 reply; 8+ messages in thread
From: Taeung Song @ 2017-02-01 12:34 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Jiri Olsa, Namhyung Kim, Ingo Molnar,
Peter Zijlstra, Wang Nan, Taeung Song
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/util/parse-events.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 0c3b81a..316f054 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -254,8 +254,7 @@ struct tracepoint_path *tracepoint_name_to_path(const char *name)
if (path->system == NULL || path->name == NULL) {
zfree(&path->system);
zfree(&path->name);
- free(path);
- path = NULL;
+ zfree(&path);
}
return path;
@@ -1482,8 +1481,7 @@ static void perf_pmu__parse_cleanup(void)
p = perf_pmu_events_list + i;
free(p->symbol);
}
- free(perf_pmu_events_list);
- perf_pmu_events_list = NULL;
+ zfree(&perf_pmu_events_list);
perf_pmu_events_list_num = 0;
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 4/4] perf tools: Use zfree() to be more safe in parse-events.c
2017-02-01 12:34 [PATCH v3 0/4] Fill in lacking parts and Refactor several parts Taeung Song
` (2 preceding siblings ...)
2017-02-01 12:34 ` [PATCH v3 3/4] perf tools: Use zfree() instead of free() and assigning NULL to the pointer Taeung Song
@ 2017-02-01 12:34 ` Taeung Song
3 siblings, 0 replies; 8+ messages in thread
From: Taeung Song @ 2017-02-01 12:34 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Jiri Olsa, Namhyung Kim, Ingo Molnar,
Peter Zijlstra, Wang Nan, Taeung Song
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/util/parse-events.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 316f054..ac47c12 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1479,7 +1479,7 @@ static void perf_pmu__parse_cleanup(void)
for (i = 0; i < perf_pmu_events_list_num; i++) {
p = perf_pmu_events_list + i;
- free(p->symbol);
+ zfree(&p->symbol);
}
zfree(&perf_pmu_events_list);
perf_pmu_events_list_num = 0;
@@ -1564,7 +1564,7 @@ perf_pmu__parse_check(const char *name)
r = bsearch(&p, perf_pmu_events_list,
(size_t) perf_pmu_events_list_num,
sizeof(struct perf_pmu_event_symbol), comp_pmu);
- free(p.symbol);
+ zfree(&p.symbol);
return r ? r->type : PMU_EVENT_SYMBOL_ERR;
}
@@ -1711,8 +1711,8 @@ static void parse_events_print_error(struct parse_events_error *err,
fprintf(stderr, "%*s\\___ %s\n", idx + 1, "", err->str);
if (err->help)
fprintf(stderr, "\n%s\n", err->help);
- free(err->str);
- free(err->help);
+ zfree(&err->str);
+ zfree(&err->help);
}
fprintf(stderr, "Run 'perf list' for a list of valid events\n");
@@ -2407,7 +2407,7 @@ void parse_events_terms__purge(struct list_head *terms)
list_for_each_entry_safe(term, h, terms, list) {
if (term->array.nr_ranges)
- free(term->array.ranges);
+ zfree(&term->array.ranges);
list_del_init(&term->list);
free(term);
}
@@ -2423,7 +2423,7 @@ void parse_events_terms__delete(struct list_head *terms)
void parse_events__clear_array(struct parse_events_array *a)
{
- free(a->ranges);
+ zfree(&a->ranges);
}
void parse_events_evlist_error(struct parse_events_evlist *data,
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip:perf/core] perf tools: Only increase index if perf_evsel__new_idx() succeeds
2017-02-01 12:34 ` [PATCH v3 1/4] perf tools: Only increase index if perf_evsel__new_idx() succeeds Taeung Song
@ 2017-02-10 7:45 ` tip-bot for Taeung Song
0 siblings, 0 replies; 8+ messages in thread
From: tip-bot for Taeung Song @ 2017-02-10 7:45 UTC (permalink / raw)
To: linux-tip-commits
Cc: treeze.taeung, peterz, linux-kernel, acme, jolsa, wangnan0,
namhyung, tglx, mingo, hpa
Commit-ID: 75fc5ae5cc53fff71041ecadeb3354a2b4c9fe42
Gitweb: http://git.kernel.org/tip/75fc5ae5cc53fff71041ecadeb3354a2b4c9fe42
Author: Taeung Song <treeze.taeung@gmail.com>
AuthorDate: Wed, 1 Feb 2017 21:34:04 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 8 Feb 2017 09:41:10 -0300
perf tools: Only increase index if perf_evsel__new_idx() succeeds
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1485952447-7013-2-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/parse-events.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6dbcba7..2720600 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -310,10 +310,11 @@ __add_event(struct list_head *list, int *idx,
event_attr_init(attr);
- evsel = perf_evsel__new_idx(attr, (*idx)++);
+ evsel = perf_evsel__new_idx(attr, *idx);
if (!evsel)
return NULL;
+ (*idx)++;
evsel->cpus = cpu_map__get(cpus);
evsel->own_cpus = cpu_map__get(cpus);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip:perf/core] perf tools: Add missing check for failure in a zalloc() call
2017-02-01 12:34 ` [PATCH v3 2/4] perf tools: Fill in a lacking part no checking NULL after zalloc() in parse-events.c Taeung Song
@ 2017-02-10 7:46 ` tip-bot for Taeung Song
0 siblings, 0 replies; 8+ messages in thread
From: tip-bot for Taeung Song @ 2017-02-10 7:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, acme, peterz, jolsa, wangnan0, mingo, linux-kernel,
namhyung, treeze.taeung, tglx
Commit-ID: 5aa365f29867eb739cde0713f00c7d80f36e0739
Gitweb: http://git.kernel.org/tip/5aa365f29867eb739cde0713f00c7d80f36e0739
Author: Taeung Song <treeze.taeung@gmail.com>
AuthorDate: Wed, 1 Feb 2017 21:34:05 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 8 Feb 2017 09:41:11 -0300
perf tools: Add missing check for failure in a zalloc() call
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1485952447-7013-3-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/parse-events.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 2720600..1f1f77d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -211,6 +211,8 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
closedir(evt_dir);
closedir(sys_dir);
path = zalloc(sizeof(*path));
+ if (!path)
+ return NULL;
path->system = malloc(MAX_EVENT_LENGTH);
if (!path->system) {
free(path);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip:perf/core] perf tools: Use zfree() instead of ad hoc equivalent
2017-02-01 12:34 ` [PATCH v3 3/4] perf tools: Use zfree() instead of free() and assigning NULL to the pointer Taeung Song
@ 2017-02-10 7:46 ` tip-bot for Taeung Song
0 siblings, 0 replies; 8+ messages in thread
From: tip-bot for Taeung Song @ 2017-02-10 7:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: peterz, jolsa, linux-kernel, treeze.taeung, wangnan0, hpa, acme,
tglx, namhyung, mingo
Commit-ID: 506fde11a35f39e1b44478339c41e94dfd278aa2
Gitweb: http://git.kernel.org/tip/506fde11a35f39e1b44478339c41e94dfd278aa2
Author: Taeung Song <treeze.taeung@gmail.com>
AuthorDate: Wed, 1 Feb 2017 21:34:06 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 8 Feb 2017 09:41:11 -0300
perf tools: Use zfree() instead of ad hoc equivalent
We have zfree(&ptr) for this very common pattern:
free(ptr);
ptr = NULL;
So use it in a few more places.
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1485952447-7013-4-git-send-email-treeze.taeung@gmail.com
[ rewrote commit log ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/parse-events.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 1f1f77d..ab1ba22 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -254,8 +254,7 @@ struct tracepoint_path *tracepoint_name_to_path(const char *name)
if (path->system == NULL || path->name == NULL) {
zfree(&path->system);
zfree(&path->name);
- free(path);
- path = NULL;
+ zfree(&path);
}
return path;
@@ -1482,8 +1481,7 @@ static void perf_pmu__parse_cleanup(void)
p = perf_pmu_events_list + i;
free(p->symbol);
}
- free(perf_pmu_events_list);
- perf_pmu_events_list = NULL;
+ zfree(&perf_pmu_events_list);
perf_pmu_events_list_num = 0;
}
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-02-10 8:43 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-01 12:34 [PATCH v3 0/4] Fill in lacking parts and Refactor several parts Taeung Song
2017-02-01 12:34 ` [PATCH v3 1/4] perf tools: Only increase index if perf_evsel__new_idx() succeeds Taeung Song
2017-02-10 7:45 ` [tip:perf/core] " tip-bot for Taeung Song
2017-02-01 12:34 ` [PATCH v3 2/4] perf tools: Fill in a lacking part no checking NULL after zalloc() in parse-events.c Taeung Song
2017-02-10 7:46 ` [tip:perf/core] perf tools: Add missing check for failure in a zalloc() call tip-bot for Taeung Song
2017-02-01 12:34 ` [PATCH v3 3/4] perf tools: Use zfree() instead of free() and assigning NULL to the pointer Taeung Song
2017-02-10 7:46 ` [tip:perf/core] perf tools: Use zfree() instead of ad hoc equivalent tip-bot for Taeung Song
2017-02-01 12:34 ` [PATCH v3 4/4] perf tools: Use zfree() to be more safe in parse-events.c Taeung Song
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.