This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: v4l2-ctl-streaming: use the error code returned by the cv4l helpers Author: Hans Verkuil <[email protected]> Date: Thu Aug 27 09:32:45 2026 +0200 The cv4l helpers return a positive errno rather than -1, so the error code has to be taken from the return value. Six call sites instead ignored the return value and read the global errno, which is not reliable: - Tracing is enabled by default (main() calls s_trace()), so on every error path v4l_named_ioctl() runs fprintf() and strerror() between the failing ioctl and the caller reading errno. - Several helper emulation paths return an errno without ever setting errno, e.g. v4l_g_selection(), v4l_s_selection() and v4l_try_ext_ctrls(). - Helpers that issue more than one ioctl can leave errno set by a call other than the one that failed. So the reported error was either a stale value or, for the qbuf() case in do_handle_cap(), a wrong comparison: the EINVAL check that suppresses the expected failure after a resolution change tested errno rather than the returned code, so it could either swallow an unrelated error or fail to recognise the EINVAL it was meant to ignore. Use the value returned by the helper in all six places. Signed-off-by: Hans Verkuil <[email protected]> Assisted-by: Claude-Code:claude-opus-5 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=46aac5d9d9ec2afa88bc338c43c85ffbb5c1f184 diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index fe5d0dfee397..f47221100e2d 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -1358,10 +1358,11 @@ static int do_setup_out_buffers(cv4l_fd &fd, cv4l_queue &q, FILE *fin, bool qbuf buf.s_request_fd(fwht_reqs[i].fd); buf.or_flags(V4L2_BUF_FLAG_REQUEST_FD); - if (set_fwht_ext_ctrl(fd, &last_fwht_hdr, last_fwht_bf_ts, - buf.g_request_fd())) { + int ret = set_fwht_ext_ctrl(fd, &last_fwht_hdr, last_fwht_bf_ts, + buf.g_request_fd()); + if (ret) { fprintf(stderr, "%s: set_fwht_ext_ctrl failed on %dth buf: %s\n", - __func__, i, strerror(errno)); + __func__, i, strerror(ret)); return QUEUE_ERROR; } } @@ -1485,7 +1486,7 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index, if (ret == EPIPE) return QUEUE_STOPPED; if (ret) { - fprintf(stderr, "%s: failed: %s\n", "VIDIOC_DQBUF", strerror(errno)); + fprintf(stderr, "%s: failed: %s\n", "VIDIOC_DQBUF", strerror(ret)); return QUEUE_ERROR; } if (buf.g_flags() & V4L2_BUF_FLAG_LAST) { @@ -1528,7 +1529,8 @@ static int do_handle_cap(cv4l_fd &fd, cv4l_queue &q, FILE *fout, int *index, * has the size that fits the old resolution and might not * fit to the new one. */ - if (fd.qbuf(buf) && errno != EINVAL) { + ret = fd.qbuf(buf); + if (ret && ret != EINVAL) { fprintf(stderr, "%s: qbuf error\n", __func__); return QUEUE_ERROR; } @@ -1672,18 +1674,20 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap return QUEUE_ERROR; } - if (set_fwht_ext_ctrl(fd, &last_fwht_hdr, last_fwht_bf_ts, - buf.g_request_fd())) { + ret = set_fwht_ext_ctrl(fd, &last_fwht_hdr, last_fwht_bf_ts, + buf.g_request_fd()); + if (ret) { fprintf(stderr, "%s: set_fwht_ext_ctrl failed: %s\n", - __func__, strerror(errno)); + __func__, strerror(ret)); return QUEUE_ERROR; } } set_time_stamp(buf); - if (fd.qbuf(buf)) { - fprintf(stderr, "%s: failed: %s\n", "VIDIOC_QBUF", strerror(errno)); + ret = fd.qbuf(buf); + if (ret) { + fprintf(stderr, "%s: failed: %s\n", "VIDIOC_QBUF", strerror(ret)); return QUEUE_ERROR; } if (fmt.g_pixelformat() == V4L2_PIX_FMT_FWHT_STATELESS) { @@ -1741,7 +1745,7 @@ static int do_handle_out_to_in(cv4l_fd &out_fd, cv4l_fd &fd, cv4l_queue &out, cv ret = out_fd.dqbuf(buf); } while (ret == EAGAIN); if (ret) { - fprintf(stderr, "%s: failed: %s\n", "VIDIOC_DQBUF", strerror(errno)); + fprintf(stderr, "%s: failed: %s\n", "VIDIOC_DQBUF", strerror(ret)); return QUEUE_ERROR; } buf.init(in, buf.g_index()); @@ -1749,7 +1753,7 @@ static int do_handle_out_to_in(cv4l_fd &out_fd, cv4l_fd &fd, cv4l_queue &out, cv if (ret == 0) ret = fd.qbuf(buf); if (ret) { - fprintf(stderr, "%s: failed: %s\n", "VIDIOC_QBUF", strerror(errno)); + fprintf(stderr, "%s: failed: %s\n", "VIDIOC_QBUF", strerror(ret)); return QUEUE_ERROR; } return 0; _______________________________________________ linuxtv-commits mailing list -- [email protected] To unsubscribe send an email to [email protected]
