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:
parent
235338eb7e
commit
fa9c5d14c9
1 changed files with 5 additions and 1 deletions
|
@ -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){
|
||||
|
|
Loading…
Add table
Reference in a new issue