All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools lib traceevent: Fix sign variable to return signed in eval_type_str()
@ 2019-10-18 21:07 Steven Rostedt
  2019-10-21 15:09 ` Namhyung Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2019-10-18 21:07 UTC (permalink / raw)
  To: LKML
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa, Namhyung Kim,
	Andrew Morton, GwanYeong Kim


From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Seems that the value returned by eval_type_str() were always unsigned, and
never signed extended. Luckily, looking at all the trace events that
actually have a signed value seldom (if ever) are negative, so this bug
never showed its face, and if it has, nobody noticed it.

Converted the sign variable to boolean while at it.

Link: http://lkml.kernel.org/r/20191013134903.5f879ad1@gandalf.local.home
Fixes: f7d82350e597d ("tools/events: Add files to create libtraceevent.a")
Reported-by: GwanYeong Kim <gy741.kim@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/event-parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index d948475585ce..2b20063813ac 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2217,7 +2217,7 @@ static char *arg_eval (struct tep_print_arg *arg);
 static unsigned long long
 eval_type_str(unsigned long long val, const char *type, int pointer)
 {
-	int sign = 0;
+	bool sign = true;
 	char *ref;
 	int len;
 
@@ -2277,7 +2277,7 @@ eval_type_str(unsigned long long val, const char *type, int pointer)
 		return (unsigned long long)(int)val & 0xffffffff;
 
 	if (strncmp(type, "unsigned ", 9) == 0) {
-		sign = 0;
+		sign = false;
 		type += 9;
 	}
 
-- 
2.20.1


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

* Re: [PATCH] tools lib traceevent: Fix sign variable to return signed in eval_type_str()
  2019-10-18 21:07 [PATCH] tools lib traceevent: Fix sign variable to return signed in eval_type_str() Steven Rostedt
@ 2019-10-21 15:09 ` Namhyung Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2019-10-21 15:09 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Arnaldo Carvalho de Melo, Ingo Molnar, Jiri Olsa,
	Andrew Morton, GwanYeong Kim

Hi Steve,

On Sat, Oct 19, 2019 at 6:07 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
>
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> Seems that the value returned by eval_type_str() were always unsigned, and
> never signed extended. Luckily, looking at all the trace events that
> actually have a signed value seldom (if ever) are negative, so this bug
> never showed its face, and if it has, nobody noticed it.
>
> Converted the sign variable to boolean while at it.
>
> Link: http://lkml.kernel.org/r/20191013134903.5f879ad1@gandalf.local.home
> Fixes: f7d82350e597d ("tools/events: Add files to create libtraceevent.a")
> Reported-by: GwanYeong Kim <gy741.kim@gmail.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks
Namhyung


> ---
>  tools/lib/traceevent/event-parse.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index d948475585ce..2b20063813ac 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -2217,7 +2217,7 @@ static char *arg_eval (struct tep_print_arg *arg);
>  static unsigned long long
>  eval_type_str(unsigned long long val, const char *type, int pointer)
>  {
> -       int sign = 0;
> +       bool sign = true;
>         char *ref;
>         int len;
>
> @@ -2277,7 +2277,7 @@ eval_type_str(unsigned long long val, const char *type, int pointer)
>                 return (unsigned long long)(int)val & 0xffffffff;
>
>         if (strncmp(type, "unsigned ", 9) == 0) {
> -               sign = 0;
> +               sign = false;
>                 type += 9;
>         }
>
> --
> 2.20.1
>

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

end of thread, other threads:[~2019-10-21 15:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18 21:07 [PATCH] tools lib traceevent: Fix sign variable to return signed in eval_type_str() Steven Rostedt
2019-10-21 15:09 ` Namhyung Kim

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.