From 58a2e315df3bc0af3918860e65a2c4dc05ae325a Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Mon, 25 Apr 2005 21:43:37 +0000 Subject: [PATCH] return errors properly in comedi_mark_buffer_read() and comedi_mark_buffer_written() --- lib/buffer.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/buffer.c b/lib/buffer.c index a3d70b3..9ebe9f2 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -84,8 +84,12 @@ int _comedi_mark_buffer_read(comedi_t *it, unsigned int subdev, unsigned int byt bi.subdevice = subdev; bi.bytes_read = bytes; ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); - __comedi_errno = errno; - if(__comedi_errno == EPIPE)__comedi_errno = EBUF_OVR; + if(ret < 0) + { + __comedi_errno = errno; + if(__comedi_errno == EPIPE)__comedi_errno = EBUF_OVR; + return ret; + } return bi.buf_write_count - bi.buf_read_count; } @@ -99,8 +103,12 @@ int _comedi_mark_buffer_written(comedi_t *it, unsigned int subdev, unsigned int bi.subdevice = subdev; bi.bytes_written = bytes; ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); - __comedi_errno = errno; - if(__comedi_errno == EPIPE)__comedi_errno = EBUF_UNDR; + if(ret < 0) + { + __comedi_errno = errno; + if(__comedi_errno == EPIPE)__comedi_errno = EBUF_UNDR; + return ret; + } return bi.buf_write_count - bi.buf_read_count; } -- 2.26.2