diff options
-rw-r--r-- | src/event-parse.c | 21 | ||||
-rw-r--r-- | utest/traceevent-utest.c | 5 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/event-parse.c b/src/event-parse.c index d607556..b625621 100644 --- a/src/event-parse.c +++ b/src/event-parse.c @@ -1232,9 +1232,11 @@ static enum tep_event_type __read_token(struct tep_handle *tep, char **tok) switch (type) { case TEP_EVENT_NEWLINE: case TEP_EVENT_DELIM: - if (asprintf(tok, "%c", ch) < 0) + *tok = malloc(2); + if (!*tok) return TEP_EVENT_ERROR; - + (*tok)[0] = ch; + (*tok)[1] = '\0'; return type; case TEP_EVENT_OP: @@ -2373,6 +2375,8 @@ process_op(struct tep_event *event, struct tep_print_arg *arg, char **tok) /* it will set arg->op.right */ type = process_cond(event, arg, tok); + if (type == TEP_EVENT_ERROR) + free(token); } else if (strcmp(token, ">>") == 0 || strcmp(token, "<<") == 0 || @@ -3732,9 +3736,20 @@ process_arg_token(struct tep_event *event, struct tep_print_arg *arg, arg->atom.atom = atom; break; - case TEP_EVENT_DQUOTE: case TEP_EVENT_SQUOTE: arg->type = TEP_PRINT_ATOM; + /* Make characters into numbers */ + if (asprintf(&arg->atom.atom, "%d", token[0]) < 0) { + free_token(token); + *tok = NULL; + arg->atom.atom = NULL; + return TEP_EVENT_ERROR; + } + free_token(token); + type = read_token_item(event->tep, &token); + break; + case TEP_EVENT_DQUOTE: + arg->type = TEP_PRINT_ATOM; arg->atom.atom = token; type = read_token_item(event->tep, &token); break; diff --git a/utest/traceevent-utest.c b/utest/traceevent-utest.c index 041843e..b95e478 100644 --- a/utest/traceevent-utest.c +++ b/utest/traceevent-utest.c @@ -216,7 +216,7 @@ DECL_CPUMASK_EVENT_DATA(bytep2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x01); #define CPUMASK_BYTEP2_FMT "cpumask=0,23" DECL_CPUMASK_EVENT_DATA(bytepn, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01); -#define CPUMASK_BYTEPN "ARRAY[80, 00, 00, 00, 00, 00, 80, 01]" +#define CPUMASK_BYTEPN "ARRAY[80, 00, 00, 00, 00, 00, 00, 01]" #define CPUMASK_BYTEPN_FMT "cpumask=0,63" #endif @@ -392,6 +392,9 @@ static int test_suite_init(void) test_tep = tep_alloc(); if (!test_tep) return 1; +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + tep_set_file_bigendian(test_tep, TEP_BIG_ENDIAN); +#endif return 0; } |