From patchwork Mon Mar 9 16:24:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3070 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 14BEB6292C for ; Mon, 9 Mar 2020 17:21:30 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id BB22460019 for ; Mon, 9 Mar 2020 16:21:29 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 9 Mar 2020 17:24:08 +0100 Message-Id: <20200309162414.720306-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200309162414.720306-1-jacopo@jmondi.org> References: <20200309162414.720306-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 05/11] libcamera: v4l2_controls: Fix usage of strerror() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2020 16:21:32 -0000 On failure, the return code from V4L2Device::ioctl() is the negative error code set by the failed ::ioctl() system call. When the return code of V4L2Device::ioctl() is provided to strerror() it has to be negated again to obtain the positive error code. Fix a few wrong usages of the return code which provided to the strerror() function a negative error code. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_device.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 98639bd0f07f..179476e9afad 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -201,13 +201,13 @@ int V4L2Device::getControls(ControlList *ctrls) /* Generic validation error. */ if (errorIdx == 0 || errorIdx >= count) { LOG(V4L2, Error) << "Unable to read controls: " - << strerror(ret); + << strerror(-ret); return -EINVAL; } /* A specific control failed. */ LOG(V4L2, Error) << "Unable to read control " << errorIdx - << ": " << strerror(ret); + << ": " << strerror(-ret); count = errorIdx - 1; ret = errorIdx; } @@ -291,13 +291,13 @@ int V4L2Device::setControls(ControlList *ctrls) /* Generic validation error. */ if (errorIdx == 0 || errorIdx >= count) { LOG(V4L2, Error) << "Unable to set controls: " - << strerror(ret); + << strerror(-ret); return -EINVAL; } /* A specific control failed. */ LOG(V4L2, Error) << "Unable to set control " << errorIdx - << ": " << strerror(ret); + << ": " << strerror(-ret); count = errorIdx - 1; ret = errorIdx; }