linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] util: constant -1 with expression of type char and allocation failure handling
@ 2024-06-19 18:38 yskelg
       [not found] ` <CAP-5=fWm-Tij+vjqOa-18RsiO+1_ytWnKkDvp3vz5hv1O9aMCw@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: yskelg @ 2024-06-19 18:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter
  Cc: kan.liang, Yang Jihong, Ze Gao, Leo Yan, Ravi Bangoria,
	Austin Kim, shjy180909, linux-perf-users, linux-kernel,
	Yunseong Kim

From: Yunseong Kim <yskelg@gmail.com>

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.

Signed-off-by: Yunseong Kim <yskelg@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] util: constant -1 with expression of type char and allocation failure handling
       [not found] ` <CAP-5=fWm-Tij+vjqOa-18RsiO+1_ytWnKkDvp3vz5hv1O9aMCw@mail.gmail.com>
@ 2024-06-19 19:10   ` Yunseong Kim
  2024-06-25  5:00     ` Namhyung Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Yunseong Kim @ 2024-06-19 19:10 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Liang, Kan,
	Yang Jihong, Ze Gao, Leo Yan, Ravi Bangoria, Austin Kim,
	shjy180909, linux-perf-users, LKML

Hi Ian,

On 6/20/24 4:03 오전, Ian Rogers wrote:
> 
> 
> On Wed, Jun 19, 2024, 11:39 AM <yskelg@gmail.com
> <mailto:yskelg@gmail.com>> wrote:
> 
>     From: Yunseong Kim <yskelg@gmail.com <mailto:yskelg@gmail.com>>
> 
>     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.
> 
>     Signed-off-by: Yunseong Kim <yskelg@gmail.com <mailto:yskelg@gmail.com>>
> 
> 
> 
> 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.

> Reviewed-by: Ian Rogers <irogers@google.com <mailto:irogers@google.com>>
> 
> 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
> 

Warm Regards,
Yunseong Kim

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] util: constant -1 with expression of type char and allocation failure handling
  2024-06-19 19:10   ` Yunseong Kim
@ 2024-06-25  5:00     ` Namhyung Kim
  2024-06-25  5:22       ` Yunseong Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2024-06-25  5:00 UTC (permalink / raw)
  To: Yunseong Kim
  Cc: Ian Rogers, Arnaldo Carvalho de Melo, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Liang, Kan,
	Yang Jihong, Ze Gao, Leo Yan, Ravi Bangoria, Austin Kim,
	shjy180909, linux-perf-users, LKML

Hello,

On Thu, Jun 20, 2024 at 04:10:53AM +0900, Yunseong Kim wrote:
> Hi Ian,
> 
> On 6/20/24 4:03 오전, Ian Rogers wrote:
> > 
> > 
> > On Wed, Jun 19, 2024, 11:39 AM <yskelg@gmail.com
> > <mailto:yskelg@gmail.com>> wrote:
> > 
> >     From: Yunseong Kim <yskelg@gmail.com <mailto:yskelg@gmail.com>>
> > 
> >     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.
> > 
> >     Signed-off-by: Yunseong Kim <yskelg@gmail.com <mailto:yskelg@gmail.com>>
> > 
> > 
> > 
> > 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.
> 
> > Reviewed-by: Ian Rogers <irogers@google.com <mailto:irogers@google.com>>

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

> > 
> > 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
> > 
> 
> Warm Regards,
> Yunseong Kim

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] util: constant -1 with expression of type char and allocation failure handling
  2024-06-25  5:00     ` Namhyung Kim
@ 2024-06-25  5:22       ` Yunseong Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Yunseong Kim @ 2024-06-25  5:22 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ian Rogers, Arnaldo Carvalho de Melo, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Liang, Kan,
	Yang Jihong, Ze Gao, Leo Yan, Ravi Bangoria, Austin Kim,
	shjy180909, linux-perf-users, LKML

Hi Namhyung,

On 6/25/24 2:00 오후, Namhyung Kim wrote:
> Hello,
> 
> On Thu, Jun 20, 2024 at 04:10:53AM +0900, Yunseong Kim wrote:
>> Hi Ian,
>>
>> On 6/20/24 4:03 오전, Ian Rogers wrote:
>>>
>>>
>>> On Wed, Jun 19, 2024, 11:39 AM <yskelg@gmail.com
>>> <mailto:yskelg@gmail.com>> wrote:
>>>
>>>     From: Yunseong Kim <yskelg@gmail.com <mailto:yskelg@gmail.com>>
>>>
>>>     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.
>>>
>>>     Signed-off-by: Yunseong Kim <yskelg@gmail.com <mailto:yskelg@gmail.com>>
>>>
>>>
>>>
>>> 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.
>>
>>> Reviewed-by: Ian Rogers <irogers@google.com <mailto:irogers@google.com>>
> 
> 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.

>>> 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
>>>
>>
>> Warm Regards,
>> Yunseong Kim

Thank you for your hard working and for always being.

Best regards,

Yunseong Kim

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-25  5:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 18:38 [PATCH] util: constant -1 with expression of type char and allocation failure handling yskelg
     [not found] ` <CAP-5=fWm-Tij+vjqOa-18RsiO+1_ytWnKkDvp3vz5hv1O9aMCw@mail.gmail.com>
2024-06-19 19:10   ` Yunseong Kim
2024-06-25  5:00     ` Namhyung Kim
2024-06-25  5:22       ` Yunseong Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).