From 42ad18e4d639f17f3e57ba4ed330cd555605b178 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 24 Jan 2012 13:43:21 +0200 Subject: warn if written size is different to original one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch also eliminates compiler warning: yavta.c: In function ‘video_save_image’: yavta.c:974:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable] Signed-off-by: Andy Shevchenko [Print different messages depending on whether the return value is negative or positive] Signed-off-by: Laurent Pinchart --- yavta.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'yavta.c') diff --git a/yavta.c b/yavta.c index b5b4487..2636577 100644 --- a/yavta.c +++ b/yavta.c @@ -1006,6 +1006,12 @@ static void video_save_image(struct device *dev, struct v4l2_buffer *buf, ret = write(fd, dev->buffers[buf->index].mem, buf->bytesused); close(fd); + + if (ret < 0) + printf("write error: %s (%d)\n", strerror(errno), errno); + else if (ret != (int)buf->bytesused) + printf("write error: only %d bytes written instead of %u\n", + ret, buf->bytesused); } static int video_do_capture(struct device *dev, unsigned int nframes, -- cgit v1.2.3