Skip to content

Commit

Permalink
listevents: Decode event list errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Kleen committed Jun 27, 2024
1 parent 1c6fd3b commit 566968a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions jevents/listevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdlib.h>
#include <string.h>
#include <fnmatch.h>
#include <errno.h>
#include <assert.h>
#include "jevents.h"

Expand Down Expand Up @@ -55,22 +56,26 @@ static int cmp_events(const void *ap, const void *bp)

int main(int ac, char **av)
{
int err;

if (av[1] && !strcmp(av[1], "-v")) {
av++;
verbose = 1;
}

if (read_events(NULL) < 0) {
fprintf(stderr, "Error reading JSON data\n");
err = read_events(NULL);
if (err < 0) {
fprintf(stderr, "Error reading JSON data: %s\n", strerror(errno));
exit(1);
}
struct walk_data wd = { .match = av[1] };
walk_events(count_event, &wd);
walk_perf_events(count_event, &wd);
wd.events = calloc(sizeof(struct event), wd.count);
walk_events(store_event, &wd);
if (walk_perf_events(store_event, &wd) < 0) {
fprintf(stderr, "Error reading perf events\n");
err = walk_perf_events(store_event, &wd);
if (err < 0) {
fprintf(stderr, "Error reading perf events: %s\n", strerror(err));
exit(1);
}
qsort(wd.events, wd.count, sizeof(struct event), cmp_events);
Expand Down

0 comments on commit 566968a

Please sign in to comment.