mark initial buffer contents as written, remove some unused variables,
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 22 Jan 2005 14:31:20 +0000 (14:31 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 22 Jan 2005 14:31:20 +0000 (14:31 +0000)
fixed buffer overrun

demo/ao_mmap.c

index 82493e05ec6bbb5490d8d06e9699432001f5df96..1646c764b4dc270a91b25c88aeab47c094ae4949 100644 (file)
@@ -70,8 +70,6 @@ int main(int argc, char *argv[])
 {
        comedi_cmd cmd;
        int err;
-       int n,m;
-       int total=0;
        comedi_t *dev;
        unsigned int chanlist[16];
        unsigned int maxdata;
@@ -150,12 +148,17 @@ int main(int argc, char *argv[])
                perror("mmap");
                exit(1);
        }
-       write_waveform(map, size, amplitude, offset, maxdata);
+       write_waveform(map, size / sizeof(sampl_t), amplitude, offset, maxdata);
        if(msync(map, size, MS_SYNC) < 0)
        {
                perror("msync");
                exit(1);
        }
+       if(comedi_mark_buffer_written(dev, subdevice, size) < 0)
+       {
+               comedi_perror("comedi_mark_buffer_written");
+               exit(1);
+       }
        ret = comedi_internal_trigger(dev, subdevice, 0);
        if(ret<0){
                comedi_perror("comedi_internal_trigger\n");