Skip to content

Commit

Permalink
plugins: filters: check for read_mt() availability
Browse files Browse the repository at this point in the history
In case users use raw modules that don't implement ts_read(), we must fail
gracefully.
  • Loading branch information
merge committed Apr 25, 2017
1 parent 2ffddd6 commit 7c5b4f8
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/debounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ static int debounce_read_mt(struct tslib_module_info *info, struct ts_sample_mt
p->current_max_slots = max_slots;
}

if (!info->next->ops->read_mt)
return -ENOSYS;

ret = info->next->ops->read_mt(info->next, samp, max_slots, nr_samples);
if (ret < 0)
return ret;
Expand Down
3 changes: 3 additions & 0 deletions plugins/dejitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ static int dejitter_read_mt(struct tslib_module_info *info,
int ret;
int i, j;

if (!info->next->ops->read_mt)
return -ENOSYS;

ret = info->next->ops->read_mt(info->next, samp, max_slots, nr);
if (ret < 0)
return ret;
Expand Down
3 changes: 3 additions & 0 deletions plugins/iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ static int iir_read_mt(struct tslib_module_info *info,
iir->slots = max_slots;
}

if (!info->next->ops->read_mt)
return -ENOSYS;

ret = info->next->ops->read_mt(info->next, samp, max_slots, nr);
if (ret < 0)
return ret;
Expand Down
3 changes: 3 additions & 0 deletions plugins/linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ static int linear_read_mt(struct tslib_module_info *info,
int i;
int nr;

if (!info->next->ops->read_mt)
return -ENOSYS;

ret = info->next->ops->read_mt(info->next, samp, max_slots, nr_samples);
if (ret < 0)
return ret;
Expand Down
3 changes: 3 additions & 0 deletions plugins/median.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ static int median_read_mt(struct tslib_module_info *inf,
int ret;
int i, j;

if (!inf->next->ops->read_mt)
return -ENOSYS;

ret = inf->next->ops->read_mt(inf->next, samp, max_slots, nr);
if (ret < 0)
return ret;
Expand Down
3 changes: 3 additions & 0 deletions plugins/pthres.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ static int pthres_read_mt(struct tslib_module_info *info,
p->current_max_slots = max_slots;
}

if (!info->next->ops->read_mt)
return -ENOSYS;

ret = info->next->ops->read_mt(info->next, samp, max_slots, nr_samples);
if (ret < 0)
return ret;
Expand Down
3 changes: 3 additions & 0 deletions plugins/skip.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ static int skip_read_mt(struct tslib_module_info *info,
skip->slots = max_slots;
}

if (!info->next->ops->read_mt)
return -ENOSYS;

ret = info->next->ops->read_mt(info->next, samp, max_slots, nr);
if (ret < 0)
return ret;
Expand Down
3 changes: 3 additions & 0 deletions plugins/variance.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ static int variance_read_mt(struct tslib_module_info *info,
short pen_down = 1;
int ret;

if (!info->next->ops->read_mt)
return -ENOSYS;

if (var->samp == NULL) {
var->samp = calloc(nr, sizeof(struct ts_sample));
if (!var->samp)
Expand Down

0 comments on commit 7c5b4f8

Please sign in to comment.