From: Frank Mori Hess Date: Mon, 25 Apr 2005 21:43:37 +0000 (+0000) Subject: return errors properly in comedi_mark_buffer_read() and X-Git-Tag: v0_8_0~104 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=58a2e315df3bc0af3918860e65a2c4dc05ae325a;p=comedilib.git return errors properly in comedi_mark_buffer_read() and comedi_mark_buffer_written() --- 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; }