Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312343
b: refs/heads/master
c: 0fed483
h: refs/heads/master
i:
  312341: 295f882
  312339: 51cf392
  312335: b95d219
v: v3
  • Loading branch information
Namhyung Kim authored and Namhyung Kim committed Jul 4, 2012
1 parent ae09129 commit 06cd84a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e54b34aed1c4082ed03f4d1f7a19276059b1e30a
refs/heads/master: 0fed48341529716c38493be66591bda458921b75
15 changes: 13 additions & 2 deletions trunk/tools/lib/traceevent/parse-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2026,11 +2026,13 @@ static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg)
char *lstr;
char *rstr;
char *op;
char *str;
char *str = NULL;
int len;

lstr = arg_to_str(filter, arg->exp.left);
rstr = arg_to_str(filter, arg->exp.right);
if (!lstr || !rstr)
goto out;

switch (arg->exp.type) {
case FILTER_EXP_ADD:
Expand Down Expand Up @@ -2070,6 +2072,7 @@ static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg)
len = strlen(op) + strlen(lstr) + strlen(rstr) + 4;
str = malloc_or_die(len);
snprintf(str, len, "%s %s %s", lstr, op, rstr);
out:
free(lstr);
free(rstr);

Expand All @@ -2086,6 +2089,8 @@ static char *num_to_str(struct event_filter *filter, struct filter_arg *arg)

lstr = arg_to_str(filter, arg->num.left);
rstr = arg_to_str(filter, arg->num.right);
if (!lstr || !rstr)
goto out;

switch (arg->num.type) {
case FILTER_CMP_EQ:
Expand Down Expand Up @@ -2122,6 +2127,7 @@ static char *num_to_str(struct event_filter *filter, struct filter_arg *arg)
break;
}

out:
free(lstr);
free(rstr);
return str;
Expand Down Expand Up @@ -2272,7 +2278,12 @@ int pevent_filter_compare(struct event_filter *filter1, struct event_filter *fil
/* The best way to compare complex filters is with strings */
str1 = arg_to_str(filter1, filter_type1->filter);
str2 = arg_to_str(filter2, filter_type2->filter);
result = strcmp(str1, str2) != 0;
if (str1 && str2)
result = strcmp(str1, str2) != 0;
else
/* bail out if allocation fails */
result = 1;

free(str1);
free(str2);
if (result)
Expand Down

0 comments on commit 06cd84a

Please sign in to comment.