util: constant -1 with expression of type char and allocation failure handling
PATCH 1/1 util: constant -1 with expression of type char and allocation failure handling
From: Yunseong Kim <[email protected]>
This patch resolve this warning.
tools/perf/util/evsel.c:1620:9: error: result of comparison of constant -1 with expression of type 'char' is always false
-Werror,-Wtautological-constant-out-of-range-compare
1620 | if (c == -1)
| ~ ^ ~~
Add handling on unread_unwind_spec_debug_frame().
This make caller find_proc_info() works well when the allocation failure.
--- tools/perf/util/evsel.c | 2 +- tools/perf/util/unwind-libunwind-local.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -1
@@ -1620,7 +1620,7 @@ static int evsel__read_group(struct evsel *leader, int cpu_map_idx, int thread)static bool read_until_char (struct io *io,char e) { -char c; +int c; do { c = io__get_char(io);
tools/perf/util/unwind-libunwind-local.c +5 -0
@@ -390,6 +390,11 @@ static int read_unwind_spec_debug_frame(struct dso *dso,char *debuglink =malloc (PATH_MAX );int ret =0 ; +if (debuglink ==NULL ) { +pr_err ("unwind: Can't read unwind spec debug frame.\n" ); +return -ENOMEM ; + } + ret =dso__read_binary_type_filename ( dso,DSO_BINARY_TYPE__DEBUGLINK , machine->root_dir, debuglink,PATH_MAX );
Signature · 1 line
2.44.0
A message that is not in the archive (sent off-list or not yet received): CAP-5=fWm-Tij+vjqOa-18RsiO+1_ytWnKkDvp3vz5hv1O9aMCw@mail.gmail.com
Hi Ian,
Quoted 19 lines · Ian Rogers
On Wed, Jun 19, 2024, 11:39 AM <[email protected]
<mailto:[email protected]>> wrote:From: Yunseong Kim <[email protected] <mailto:[email protected]>>
This patch resolve this warning.
tools/perf/util/evsel.c:1620:9: error: result of comparison of constant -1 with expression of type 'char' is always false -Werror,-Wtautological-constant-out-of-range-compare
1620 | if (c == -1)
| ~ ^ ~~Add handling on
unread_unwind_spec_debug_frame(). This make callerfind_proc_info()works well when the allocation failure.
Quoted 5 lines
Signed-off-by Yunseong Kim <[email protected] <mailto:[email protected]>>Both changes look good. Could you make them 2 commits? If so add my:
No problem! I'll send it right away.
Thank you for the code review.
Quoted 37 lines
Reviewed-by Ian Rogers <[email protected] <mailto:[email protected]>>Thanks,
Ian--- tools/perf/util/evsel.c | 2 +- tools/perf/util/unwind-libunwind-local.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 25857894c047..bc603193c477 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1620,7 +1620,7 @@ static int evsel__read_group(struct evsel *leader, int cpu_map_idx, int thread) static bool read_until_char(struct io *io, char e) { - char c; + int c; do { c = io__get_char(io); diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index cde267ea3e99..a424eae6d308 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -390,6 +390,11 @@ static int read_unwind_spec_debug_frame(struct dso *dso, char *debuglink = malloc(PATH_MAX); int ret = 0; + if (debuglink == NULL) { + pr_err("unwind: Can't read unwind spec debug frame.\n");
Quoted 9 lines
+ return -ENOMEM;
+ }
+
ret = dso__read_binary_type_filename(
dso, DSO_BINARY_TYPE__DEBUGLINK,
machine->root_dir, debuglink, PATH_MAX);
--
2.44.0Warm Regards,
Yunseong Kim
Namhyung Kim
maintainerHello,
Quoted 26 lines · Yunseong Kim
Hi Ian,
Quoted 23 lines · Ian Rogers
On Wed, Jun 19, 2024, 11:39 AM <[email protected]
<mailto:[email protected]>> wrote:From: Yunseong Kim <[email protected] <mailto:[email protected]>>
This patch resolve this warning.
tools/perf/util/evsel.c:1620:9: error: result of comparison of constant -1 with expression of type 'char' is always false -Werror,-Wtautological-constant-out-of-range-compare
1620 | if (c == -1)
| ~ ^ ~~Add handling on
unread_unwind_spec_debug_frame(). This make callerfind_proc_info()works well when the allocation failure.Signed-off-by Yunseong Kim <[email protected] <mailto:[email protected]>>
Quoted 7 lines
Quoted 1 line
Both changes look good. Could you make them 2 commits? If so add my:
No problem! I'll send it right away.
Thank you for the code review.
Quoted 1 line
Reviewed-by Ian Rogers <[email protected] <mailto:[email protected]>>
You forgot to add Ian's Reviewed-by in the next patches. I can add it to them this time, but please do so next time.
Thanks,
Namhyung
Quoted 48 lines
Quoted 36 lines
Thanks,
Ian--- tools/perf/util/evsel.c | 2 +- tools/perf/util/unwind-libunwind-local.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 25857894c047..bc603193c477 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1620,7 +1620,7 @@ static int evsel__read_group(struct evsel *leader, int cpu_map_idx, int thread) static bool read_until_char(struct io *io, char e) { - char c; + int c; do { c = io__get_char(io); diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index cde267ea3e99..a424eae6d308 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -390,6 +390,11 @@ static int read_unwind_spec_debug_frame(struct dso *dso, char *debuglink = malloc(PATH_MAX); int ret = 0; + if (debuglink == NULL) { + pr_err("unwind: Can't read unwind spec debug frame.\n");Quoted 9 lines
+ return -ENOMEM; + } + ret = dso__read_binary_type_filename( dso, DSO_BINARY_TYPE__DEBUGLINK, machine->root_dir, debuglink, PATH_MAX); -- 2.44.0Warm Regards,
Yunseong Kim
Hi Namhyung,
Quoted 35 lines · Namhyung Kim
Hello,
Quoted 32 lines · Yunseong Kim
Hi Ian,
Quoted 19 lines · Ian Rogers
On Wed, Jun 19, 2024, 11:39 AM <[email protected]
<mailto:[email protected]>> wrote:From: Yunseong Kim <[email protected] <mailto:[email protected]>>
This patch resolve this warning.
tools/perf/util/evsel.c:1620:9: error: result of comparison of constant -1 with expression of type 'char' is always false -Werror,-Wtautological-constant-out-of-range-compare
1620 | if (c == -1)
| ~ ^ ~~Add handling on
unread_unwind_spec_debug_frame(). This make callerfind_proc_info()works well when the allocation failure.Quoted 5 lines
Signed-off-by Yunseong Kim <[email protected] <mailto:[email protected]>>Both changes look good. Could you make them 2 commits? If so add my:
No problem! I'll send it right away.
Thank you for the code review.
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Reviewed-by Ian Rogers <[email protected] <mailto:[email protected]>>You forgot to add Ian's Reviewed-by in the next patches. I can add it to them this time, but please do so next time.
Thanks,
Namhyung
Thank you Namhyung for the code review. Oops, I completely forgot about that, I'm so sorry.
Quoted 45 lines
Quoted 45 lines
Quoted 44 lines
Thanks,
Ian--- tools/perf/util/evsel.c | 2 +- tools/perf/util/unwind-libunwind-local.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 25857894c047..bc603193c477 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1620,7 +1620,7 @@ static int evsel__read_group(struct evsel *leader, int cpu_map_idx, int thread) static bool read_until_char(struct io *io, char e) { - char c; + int c; do { c = io__get_char(io); diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index cde267ea3e99..a424eae6d308 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -390,6 +390,11 @@ static int read_unwind_spec_debug_frame(struct dso *dso, char *debuglink = malloc(PATH_MAX); int ret = 0; + if (debuglink == NULL) { + pr_err("unwind: Can't read unwind spec debug frame.\n"); + return -ENOMEM; + } + ret = dso__read_binary_type_filename( dso, DSO_BINARY_TYPE__DEBUGLINK, machine->root_dir, debuglink, PATH_MAX); -- 2.44.0
Quoted 2 lines
Quoted 2 lines
Warm Regards,
Yunseong Kim
Thank you for your hard working and for always being.
Best regards,
Yunseong Kim