From patchwork Fri Apr 26 15:01:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1107 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BE12D60E9A for ; Fri, 26 Apr 2019 17:02:09 +0200 (CEST) Received: from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 53758337 for ; Fri, 26 Apr 2019 17:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556290929; bh=vOFvJ00xOx/+CxLYLuN5oZBPNBjxDDzy+HvXyxArXYE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ee+SZmI+k24I/qMzfETIH0elRa9uDEYIoPdujaHXsowSKxdpFHS0s/8dHal+e4DEv THi4XU/zTjeig/XFKG36fLdQo7UaG5f8bP1TYHotCrpONmr+9v7s/Z8p6PBaUlxleS ixp3TH6QGDIgIPr+1d0RTk8zZfaT4Auj3VzSNUUc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Apr 2019 18:01:48 +0300 Message-Id: <20190426150155.18652-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> References: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/8] libcamera: Correct struct forward declarations X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 15:02:10 -0000 Several structures are forward-declarated as classes. Fix this by using the struct keyword where appropriate, or removing the forward declaration when not needed. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/camera.h | 3 ++- src/libcamera/include/camera_sensor.h | 3 ++- src/libcamera/include/pipeline_handler.h | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index b2dafda342fe..777b7e4d48b8 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -21,9 +21,10 @@ class Buffer; class PipelineHandler; class Request; class Stream; -class StreamConfiguration; class StreamUsage; +struct StreamConfiguration; + class CameraConfiguration { public: diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h index 7f2f906be8df..b823480241a7 100644 --- a/src/libcamera/include/camera_sensor.h +++ b/src/libcamera/include/camera_sensor.h @@ -18,7 +18,8 @@ namespace libcamera { class MediaEntity; class V4L2Subdevice; -class V4L2SubdeviceFormat; + +struct V4L2SubdeviceFormat; class CameraSensor : protected Loggable { diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index c3f7d4c29205..5830e53108fa 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -26,7 +26,6 @@ class MediaDevice; class PipelineHandler; class Request; class Stream; -class StreamConfiguration; class StreamUsage; class CameraData From patchwork Fri Apr 26 15:01:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1108 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0322D60E9C for ; Fri, 26 Apr 2019 17:02:10 +0200 (CEST) Received: from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9972A54C for ; Fri, 26 Apr 2019 17:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556290929; bh=heOyTImYa5Vv7LOX2E+/yZQBGwhUuoN0exFMit7GV2A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CfRLVq8AxOdBqPBJjwDCpgqdU5pbIDEAAlyVd1H9ryKeYjx/EpgjTFwo60wSwwoEf 91h/MXuBTb3UTJ6uHg4ORU2jgL8jIfRSG+jwr7w5x5/dLp5dsefU41cRdCXidSixfS 3k2eb0opHSYru/pWge9p3K9/qNJAGNgOP6e9kxGQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Apr 2019 18:01:49 +0300 Message-Id: <20190426150155.18652-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> References: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/8] libcamera: event_dispatcher_poll: Fix bitwise test X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 15:02:10 -0000 Add missing parentheses to fix a bitwise test. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/event_dispatcher_poll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/event_dispatcher_poll.cpp b/src/libcamera/event_dispatcher_poll.cpp index 130b5e20ea09..1f0f352a8e0a 100644 --- a/src/libcamera/event_dispatcher_poll.cpp +++ b/src/libcamera/event_dispatcher_poll.cpp @@ -210,7 +210,7 @@ int EventDispatcherPoll::poll(std::vector *pollfds) void EventDispatcherPoll::processInterrupt(const struct pollfd &pfd) { - if (!pfd.revents & POLLIN) + if (!(pfd.revents & POLLIN)) return; uint64_t value; From patchwork Fri Apr 26 15:01:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1109 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4AE5060E9D for ; Fri, 26 Apr 2019 17:02:10 +0200 (CEST) Received: from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DAE845F for ; Fri, 26 Apr 2019 17:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556290930; bh=CWhpKrRm0/rXUC2F3qc0D6NMeUmhc48wGmzSSiqj2ek=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ze+tjT7B9boZqaTHk/havQubzbSrjzptxkx8AF2/XPBCmW/S7pdKJLNlJKkNelU2O 0s657hV20pSI7sGZm5HGLQro53OVOgPl2uohYyfsz7HVNCcWbIS0qX3HVY71M6bqhN w0UTEVIWs8TdfRZfO77AxfFCL6J8tRdUIOlt8fHg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Apr 2019 18:01:50 +0300 Message-Id: <20190426150155.18652-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> References: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/8] libcamera: log: Add a LogInvalid entry to LogSeverity X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 15:02:10 -0000 enum LogSeverity values are assigned or compared to -1 to flag invalid log severities. This generates compilation warnings with clang. Fix it by adding an explicit LogInvalid entry to the enumeration. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/include/log.h | 3 ++- src/libcamera/log.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h index 35a6fc105448..802836d23bf2 100644 --- a/src/libcamera/include/log.h +++ b/src/libcamera/include/log.h @@ -12,7 +12,8 @@ namespace libcamera { enum LogSeverity { - LogDebug, + LogInvalid = -1, + LogDebug = 0, LogInfo, LogWarning, LogError, diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp index ebf553300f5b..0ba276e5707f 100644 --- a/src/libcamera/log.cpp +++ b/src/libcamera/log.cpp @@ -174,7 +174,7 @@ void Logger::parseLogLevels() continue; LogSeverity severity = parseLogLevel(level); - if (severity == -1) + if (severity == LogInvalid) continue; levels_.push_back({ category, severity }); @@ -189,7 +189,7 @@ void Logger::parseLogLevels() * LogFatal, or as a string corresponding to the severity name in uppercase. Any * other value is invalid. * - * \return The log severity, or -1 if the string is invalid + * \return The log severity, or LogInvalid if the string is invalid */ LogSeverity Logger::parseLogLevel(const std::string &level) { @@ -207,9 +207,9 @@ LogSeverity Logger::parseLogLevel(const std::string &level) char *endptr; severity = strtoul(level.c_str(), &endptr, 10); if (*endptr != '\0' || severity > LogFatal) - severity = -1; + severity = LogInvalid; } else { - severity = -1; + severity = LogInvalid; for (unsigned int i = 0; i < ARRAY_SIZE(names); ++i) { if (names[i] == level) { severity = i; @@ -416,13 +416,13 @@ LogMessage::LogMessage(const char *fileName, unsigned int line, * on the compiler type and version, and optimization level, the move * constructor is defined even if it will likely never be called, and ensures * that the destructor of the \a other message will not output anything to the - * log by setting the severity to -1. + * log by setting the severity to LogInvalid. */ LogMessage::LogMessage(LogMessage &&other) : msgStream_(std::move(other.msgStream_)), category_(other.category_), severity_(other.severity_) { - other.severity_ = static_cast(-1); + other.severity_ = LogInvalid; } void LogMessage::init(const char *fileName, unsigned int line) @@ -445,7 +445,7 @@ void LogMessage::init(const char *fileName, unsigned int line) LogMessage::~LogMessage() { /* Don't print anything if we have been moved to another LogMessage. */ - if (severity_ == -1) + if (severity_ == LogInvalid) return; msgStream_ << std::endl; From patchwork Fri Apr 26 15:01:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1110 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F74B60E9D for ; Fri, 26 Apr 2019 17:02:10 +0200 (CEST) Received: from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3CD42337 for ; Fri, 26 Apr 2019 17:02:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556290930; bh=+g7XL9MkRgmi1wnuS4mDMwSVtS3hzVZ9wR64ST7p3wI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jHBW37JEFfpK5Micm8928y1SEAfyXGJ8+iXcPYH7XOdbTVn3T6GNP2KHptszW9c/C cgh5tUeI3lSYkJ6rKcgm2G7qz1wsJ8C2MQQUFUl5TJ2zb1K/8aUIFTmeimQ0g8TuW1 h8ss+CmpI3YMtL5W0B6UsJgKLDmDByC8YFz4FTmQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Apr 2019 18:01:51 +0300 Message-Id: <20190426150155.18652-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> References: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/8] libcamera: Mark overridden functions with override X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 15:02:10 -0000 Several overridden virtual functions are not marked with override. Fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +- src/libcamera/pipeline/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 2c2929207d35..97a309207621 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -167,7 +167,7 @@ public: int queueRequest(Camera *camera, Request *request) override; - bool match(DeviceEnumerator *enumerator); + bool match(DeviceEnumerator *enumerator) override; private: class IPU3CameraData : public CameraData diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index b8f634d88b46..2f9b5e0fdc08 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -42,7 +42,7 @@ public: int queueRequest(Camera *camera, Request *request) override; - bool match(DeviceEnumerator *enumerator); + bool match(DeviceEnumerator *enumerator) override; private: class UVCCameraData : public CameraData diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 22449e47bc2d..f70b4d3c6bab 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -42,7 +42,7 @@ public: int queueRequest(Camera *camera, Request *request) override; - bool match(DeviceEnumerator *enumerator); + bool match(DeviceEnumerator *enumerator) override; private: class VimcCameraData : public CameraData From patchwork Fri Apr 26 15:01:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1111 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F156160E9D for ; Fri, 26 Apr 2019 17:02:10 +0200 (CEST) Received: from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8FA9A5F for ; Fri, 26 Apr 2019 17:02:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556290930; bh=m3PfYlp0guQw8AWHBXLienX/vV8XL3Q2hiab8KCQcSE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eIqFJIG/I37Wm2alMhjYGfEth85rpokHg62lieBszSWFESTEY32+Zs7FEdY/NiPGH x1C4IiWp5aGhn2gKDm0hd93vTJSnLXtS6UMPVx2P6LIfD9RjSVezIpAHwjv5+3NU5H ndY+9Etchrl72ZyQqIo2/JTThd0WJlY68ha4OLOM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Apr 2019 18:01:52 +0300 Message-Id: <20190426150155.18652-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> References: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/8] libcamera: v4l2_device: Buffer is not a struct X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 15:02:11 -0000 Buffer is a class, not a struct. Fix a variable declaration accordingly. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/v4l2_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 8d8c7887bf71..cfdce4813da4 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -622,7 +622,7 @@ int V4L2Device::exportBuffers(BufferPool *pool) for (i = 0; i < pool->count(); ++i) { struct v4l2_plane planes[VIDEO_MAX_PLANES] = {}; struct v4l2_buffer buf = {}; - struct Buffer &buffer = pool->buffers()[i]; + Buffer &buffer = pool->buffers()[i]; buf.index = i; buf.type = bufferType_; From patchwork Fri Apr 26 15:01:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1112 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CE8060EA2 for ; Fri, 26 Apr 2019 17:02:11 +0200 (CEST) Received: from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DF1A6337 for ; Fri, 26 Apr 2019 17:02:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556290931; bh=LP1in9EHTtSqNsyxOHnHOkfMJI7ghY04OLOQ0LsqL0I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tRlSdH67W2IHExsfo39p8L794RA44GYxgYjeclvkTzm/Zbz+seJdWb+hkrn97Ydwi wcVLDN4xAzAYgh/xp7MXpr+fCKzCiT1ILo80B1knKE/v6q3Nr3vX4T6v+jiiisvSmG FfE6c09jxiuIhlTCyhZRCd1OEl6bkpzba0tiYn1U= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Apr 2019 18:01:53 +0300 Message-Id: <20190426150155.18652-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> References: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/8] test: v4l2_subdevice: Remove std::move() that prevents copy elision X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 15:02:13 -0000 Moving a temporary value prevents copy elision. Remove it. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/v4l2_subdevice/v4l2_subdevice_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.cpp b/test/v4l2_subdevice/v4l2_subdevice_test.cpp index dfcf779af95e..72d5f72543d2 100644 --- a/test/v4l2_subdevice/v4l2_subdevice_test.cpp +++ b/test/v4l2_subdevice/v4l2_subdevice_test.cpp @@ -39,7 +39,7 @@ int V4L2SubdeviceTest::init() } DeviceMatch dm("vimc"); - media_ = std::move(enumerator_->search(dm)); + media_ = enumerator_->search(dm); if (!media_) { cerr << "Unable to find \'vimc\' media device node" << endl; return TestSkip; From patchwork Fri Apr 26 15:01:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1113 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AA1A960EA8 for ; Fri, 26 Apr 2019 17:02:11 +0200 (CEST) Received: from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3C8F25F for ; Fri, 26 Apr 2019 17:02:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556290931; bh=CjVvA36ESYJORGQ4okkGYCMtDeng9tzeJjBZXbO7KH4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gpt5EeTSvYGaJEclCGn9GWwUPIcqXAeQW8pJOfKDLYzmaZfEYm0z3ZLGTuprDdQDK ZKc23nYPPFndwvFEQg+1jkj9zx3xzvQ5C2ofoy2p8EVtSXPU4vtnqac+0iUXbf+b4s AOA1+ppXBGjk1w/XQpxb5LnorFxQ0tFX6t1lW5KA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Apr 2019 18:01:54 +0300 Message-Id: <20190426150155.18652-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> References: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 7/8] cam: options: Don't initialise variable-length arrays X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 15:02:13 -0000 According to clang, variable-length arrays can't be initialised. Don't do so, and explicitly set the last element to 0 instead. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/cam/options.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 172d40f76a05..b80d361eaaf4 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -382,8 +382,8 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv) * Allocate short and long options arrays large enough to contain all * options. */ - char shortOptions[options_.size() * 3 + 2] = {}; - struct option longOptions[options_.size() + 1] = {}; + char shortOptions[options_.size() * 3 + 2]; + struct option longOptions[options_.size() + 1]; unsigned int ids = 0; unsigned int idl = 0; @@ -419,6 +419,9 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv) } } + shortOptions[ids] = '\0'; + memset(&longOptions[idl], 0, sizeof(longOptions[idl])); + opterr = 0; while (true) { From patchwork Fri Apr 26 15:01:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1114 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA38960EAB for ; Fri, 26 Apr 2019 17:02:11 +0200 (CEST) Received: from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 89B25337 for ; Fri, 26 Apr 2019 17:02:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556290931; bh=tG8x2XpZGO+G4aG01WPWdtBoFK80P1WKQj4cDpkWTh0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pPqDZALveX8SzyklIWAJcLhKIdYhqcGA+Yieeyu0vghPRVYvvWoRm7sbgWA0P8a9+ 5VjbWzwHHKPaEX2nM16GTf+6qVNPTuw6dkWWDhnUlzFy+FIN+p1UDmbVcYDplDhxgJ WHNoIckp5y+6aYbfbMOxpCJssc+E5Rpm/vbLFJww= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Apr 2019 18:01:55 +0300 Message-Id: <20190426150155.18652-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> References: <20190426150155.18652-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 8/8] cam: options: Fix string concatenation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 15:02:13 -0000 Adding an integer value to a char pointer doesn't concatenate strings, it indexes in the pointed string. Fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/cam/options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cam/options.cpp b/src/cam/options.cpp index b80d361eaaf4..bea4a600d1d5 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -530,7 +530,7 @@ void OptionsParser::parseValueError(const Option &option) if (option.name) optionName = "--" + std::string(option.name); else - optionName = "-" + static_cast(option.opt); + optionName = "-" + std::string(1, option.opt); std::cerr << "Can't parse " << option.typeName() << " argument for option " << optionName << std::endl;