Skip to contentSkip to conversation

tools lib traceevent: Fix sign variable to return signed in eval_type_str()

PATCH In review Steven Rostedt 2 participants 2 messages Oct 18, 2019 – Oct 21, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools lib traceevent: Fix sign variable to return signed in eval_type_str()

From: "Steven Rostedt (VMware)" <[email protected]>

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.

Fixes f7d82350e597d ("tools/events: Add files to create libtraceevent.a")
---
 tools/lib/traceevent/event-parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/traceevent/event-parse.c +2 -2
index d948475585ce..2b20063813ac 100644
@@ -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;
 	}
 
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw

Hi Steve,

Quoted 9 lines · Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

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.

Quoted 6 lines

Converted the sign variable to boolean while at it.

Fixes f7d82350e597d ("tools/events: Add files to create libtraceevent.a")

Thanks
Namhyung

Quoted 29 lines
---
 tools/lib/traceevent/event-parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/traceevent/event-parse.c +2 -3
index d948475585ce..2b20063813ac 100644
@@ -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