demo/mmap: limit options.n_chan to 256

Set new macro N_CHANS to 256 - the length of the chanlist[] array.

If the '-n' option sets options.n_chan higher than N_CHANS, reduce it to
avoid overrunning the chanlist[] array.
This commit is contained in:
Ian Abbott 2016-11-08 14:57:16 +00:00
parent 235338eb7e
commit fa9c5d14c9

View file

@ -26,7 +26,8 @@
#include <string.h>
#include "examples.h"
unsigned int chanlist[256];
#define N_CHANS 256
unsigned int chanlist[N_CHANS];
void *map;
@ -52,6 +53,9 @@ int main(int argc, char *argv[])
init_parsed_options(&options);
options.subdevice = -1;
parse_options(&options, argc, argv);
if(options.n_chan > N_CHANS){
options.n_chan = N_CHANS;
}
dev = comedi_open(options.filename);
if(!dev){