Commit 931ef5dc authored by John Garry's avatar John Garry Committed by Arnaldo Carvalho de Melo

perf vendor events: Fix error code in json_events()

When EXPECT macro fails an assertion, the error code is not properly set
after the first loop of tokens in function json_events().

This is because err is set to the return value from func function
pointer call, which must be 0 to continue to loop, yet it is not reset
for for each loop. I assume that this was not the intention, so change
the code so err is set appropriately in EXPECT macro itself.

In addition to this, the indention in EXPECT macro is tidied. The
current indention alludes that the 2 statements following the if
statement are in the body, which is not true.
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: William Cohen <wcohen@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linuxarm@huawei.com
Link: http://lkml.kernel.org/r/1520506716-197429-3-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4c0ab160
...@@ -249,9 +249,10 @@ static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val) ...@@ -249,9 +249,10 @@ static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val)
jsmntok_t *loc = (t); \ jsmntok_t *loc = (t); \
if (!(t)->start && (t) > tokens) \ if (!(t)->start && (t) > tokens) \
loc = (t) - 1; \ loc = (t) - 1; \
pr_err("%s:%d: " m ", got %s\n", fn, \ pr_err("%s:%d: " m ", got %s\n", fn, \
json_line(map, loc), \ json_line(map, loc), \
json_name(t)); \ json_name(t)); \
err = -EIO; \
goto out_free; \ goto out_free; \
} } while (0) } } while (0)
...@@ -416,7 +417,7 @@ int json_events(const char *fn, ...@@ -416,7 +417,7 @@ int json_events(const char *fn,
char *metric_name, char *metric_group), char *metric_name, char *metric_group),
void *data) void *data)
{ {
int err = -EIO; int err;
size_t size; size_t size;
jsmntok_t *tokens, *tok; jsmntok_t *tokens, *tok;
int i, j, len; int i, j, len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment