From 2bf8d7675dbedb86a33b76c284c265e7b3596001 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sun, 8 Jul 2001 21:46:44 +0000 Subject: [PATCH] Fixed oops in das16_cmd_test() because cmd->chanlist was NULL. --- comedi/drivers/das16.c | 43 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/comedi/drivers/das16.c b/comedi/drivers/das16.c index a55485be..4f5d0a10 100644 --- a/comedi/drivers/das16.c +++ b/comedi/drivers/das16.c @@ -699,22 +699,6 @@ static int das16_cmd_test(comedi_device *dev,comedi_subdevice *s, comedi_cmd *cm err++; } } - // check channel/gain list against card's limitations - gain = CR_RANGE(cmd->chanlist[0]); - start_chan = CR_CHAN(cmd->chanlist[0]); - for(i = 1; i < cmd->chanlist_len; i++) - { - if(CR_CHAN(cmd->chanlist[i]) != (start_chan + i) % s->n_chan) - { - comedi_error(dev, "entries in chanlist must be consecutive channels, counting upwards\n"); - err++; - } - if(CR_RANGE(cmd->chanlist[i]) != gain) - { - comedi_error(dev, "entries in chanlist must all have the same gain\n"); - err++; - } - } if(err)return 3; // step 4: fix up arguments @@ -723,13 +707,36 @@ static int das16_cmd_test(comedi_device *dev,comedi_subdevice *s, comedi_cmd *cm // set divisors, correct timing arguments i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1), &(devpriv->divisor2), &(cmd->scan_begin_arg), cmd->flags & TRIG_ROUND_MASK); - } + err++; + } if(cmd->convert_src == TRIG_TIMER) { // set divisors, correct timing arguments i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1), &(devpriv->divisor2), &(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK); - } + err++; + } + if(err)return 4; + + // check channel/gain list against card's limitations + if(cmd->chanlist){ + gain = CR_RANGE(cmd->chanlist[0]); + start_chan = CR_CHAN(cmd->chanlist[0]); + for(i = 1; i < cmd->chanlist_len; i++) + { + if(CR_CHAN(cmd->chanlist[i]) != (start_chan + i) % s->n_chan) + { + comedi_error(dev, "entries in chanlist must be consecutive channels, counting upwards\n"); + err++; + } + if(CR_RANGE(cmd->chanlist[i]) != gain) + { + comedi_error(dev, "entries in chanlist must all have the same gain\n"); + err++; + } + } + } + if(err)return 5; return 0; } -- 2.26.2