From 1c2f58b13412bb91c4802ac0b6b38de494c821da Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 9 Nov 2007 15:19:36 +0000 Subject: [PATCH] For cmdtest, don't return 5 if chanlist_len == 0. --- comedi/drivers/amplc_pci224.c | 76 ++++++++++++++++------------------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/comedi/drivers/amplc_pci224.c b/comedi/drivers/amplc_pci224.c index 2a87ca12..d789525c 100644 --- a/comedi/drivers/amplc_pci224.c +++ b/comedi/drivers/amplc_pci224.c @@ -961,51 +961,43 @@ pci224_ao_cmdtest(comedi_device * dev, comedi_subdevice * s, comedi_cmd * cmd) /* Step 5: check channel list. */ - if (cmd->chanlist) { - if (cmd->chanlist_len > 0) { - unsigned int range; - enum { range_err = 1, dupchan_err = 2, }; - unsigned errors; - unsigned int n; - unsigned int ch; + if (cmd->chanlist && (cmd->chanlist_len > 0)) { + unsigned int range; + enum { range_err = 1, dupchan_err = 2, }; + unsigned errors; + unsigned int n; + unsigned int ch; - /* - * Check all channels have the same range index. Don't - * care about analogue reference, as we can't configure - * it. - * - * Check the list has no duplicate channels. - */ - range = CR_RANGE(cmd->chanlist[0]); - errors = 0; - tmp = 0; - for (n = 0; n < cmd->chanlist_len; n++) { - ch = CR_CHAN(cmd->chanlist[n]); - if (tmp & (1U << ch)) { - errors |= dupchan_err; - } - tmp |= (1U << ch); - if (CR_RANGE(cmd->chanlist[n]) != range) { - errors |= range_err; - } + /* + * Check all channels have the same range index. Don't care + * about analogue reference, as we can't configure it. + * + * Check the list has no duplicate channels. + */ + range = CR_RANGE(cmd->chanlist[0]); + errors = 0; + tmp = 0; + for (n = 0; n < cmd->chanlist_len; n++) { + ch = CR_CHAN(cmd->chanlist[n]); + if (tmp & (1U << ch)) { + errors |= dupchan_err; } - if (errors) { - if (errors & dupchan_err) { - comedi_error(dev, - "entries in chanlist must " - "contain no duplicate " - "channels\n"); - } - if (errors & range_err) { - comedi_error(dev, - "entries in chanlist must " - "all have the same range " - "index\n"); - } - err++; + tmp |= (1U << ch); + if (CR_RANGE(cmd->chanlist[n]) != range) { + errors |= range_err; + } + } + if (errors) { + if (errors & dupchan_err) { + comedi_error(dev, + "entries in chanlist must contain no " + "duplicate channels\n"); + } + if (errors & range_err) { + comedi_error(dev, + "entries in chanlist must all have " + "the same range index\n"); } - } else { - /* cmd->chanlist_len == 0 */ err++; } } -- 2.26.2