From patchwork Thu Jan 17 20:20:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 257 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 102D560B2D for ; Thu, 17 Jan 2019 21:20:49 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 70B2C558; Thu, 17 Jan 2019 21:20:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1547756448; bh=/wol2C7SFb/6v3zR6PILBgk5x6EO0TLGLvwQnvpbflM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PWC3bWNvOiSLBGI9HnwkA5lVsGPF95AfgfxhuG8PkT6dZV8ITjiTWMJZBAmku9gz6 99pR15/hwMB7f/v0Ow8vYaUkXEVcBJ/bJt5UY4JHrd/bc9UwqmHXObr+LevFo24mqV odsr+8B1foNjPGvbS+/ac6+aKgZU38A6/fM3Kn7o= From: Kieran Bingham To: LibCamera Devel Date: Thu, 17 Jan 2019 20:20:39 +0000 Message-Id: <20190117202043.21420-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> References: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> Subject: [libcamera-devel] [PATCH 1/5] test: timer: Initialise all variables 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: Thu, 17 Jan 2019 20:20:49 -0000 The ManagedTimer does not initialise the integer 'interval_' variable. This is set before used, and should not break - but for completeness (and to cover static analysers) initialise the variable in the initialiser list. Fixes: 034ea868027d ("test: Add timer test") Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- test/timer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/timer.cpp b/test/timer.cpp index 6a3cda70bef4..3d1a78ac2768 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -19,7 +19,8 @@ using namespace libcamera; class ManagedTimer : public Timer { public: - ManagedTimer() : Timer() + ManagedTimer() : + Timer(), interval_(0) { timeout.connect(this, &ManagedTimer::timeoutHandler); } From patchwork Thu Jan 17 20:20:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 258 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 3569660C99 for ; Thu, 17 Jan 2019 21:20:49 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BB4C5B6B; Thu, 17 Jan 2019 21:20:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1547756448; bh=mGxI1pXDUlKvzQmSElf6jIE60e9w0WyjvPGhVKWrvic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=luO2Vua1ec2rSNVOzfUjHvd2gPj8yGW1uJifK9RpdCawXG0JmTMh+nlt88rn8QxSs mdrnKvyeOFUkjH90DaspHPoIdOrChdYMJifDawbrM5I99wOlAgFKf8ir2lQKrt07G0 mjUDIq8Iu9SD0LI5Bu+yQ/w83oU/xltbLddzgDdc= From: Kieran Bingham To: LibCamera Devel Date: Thu, 17 Jan 2019 20:20:40 +0000 Message-Id: <20190117202043.21420-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> References: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> Subject: [libcamera-devel] [PATCH 2/5] test: timer: Add a 32 bit wraparound 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: Thu, 17 Jan 2019 20:20:49 -0000 Add a test which catches a timer running longer than the nanosecond resolution of 32 bits. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- test/timer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/timer.cpp b/test/timer.cpp index 3d1a78ac2768..c6a6ede73486 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -81,6 +81,19 @@ protected: return TestFail; } + /* + * 32 bit wrap test + * Nanosecond resolution in a 32 bit value wraps at 4.294967 + * seconds (0xFFFFFFFF / 1000000) + */ + timer.start(4295); + dispatcher->processEvents(); + + if (timer.isRunning() || timer.jitter() > 50) { + cout << "Timer expiration test failed" << endl; + return TestFail; + } + /* Timer restart. */ timer.start(500); From patchwork Thu Jan 17 20:20:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 259 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 883B060C99 for ; Thu, 17 Jan 2019 21:20:49 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1585C53E; Thu, 17 Jan 2019 21:20:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1547756449; bh=6eiqsPmV12U1svjkzaXOSeM2wvyiYx1BHjNTRtf1rwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lw1shtIAaJrMRneOwA9P9DjCjnRPBPXmHyAb3OZ1i4u9hkJwhcI/jPkIooZwftxFd 9st0kZJS+VTBgWofi6QW4oHOQifo8AkKVsDbn8kC2W+rjGFLPzoQaFpXhB6p1DmmnZ 1F6BDpY5a6lNgGDYSXy3ywdw4uuybKnOyxl3gh2c= From: Kieran Bingham To: LibCamera Devel Date: Thu, 17 Jan 2019 20:20:41 +0000 Message-Id: <20190117202043.21420-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> References: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> Subject: [libcamera-devel] [PATCH 3/5] libcamera: timer: Fix 32 bit wrap 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: Thu, 17 Jan 2019 20:20:49 -0000 The msec parameter was multiplied as a 32 bit value when converting to nanosecond resolution. This wraps at 4.2949 seconds, and causes timers longer than this to fail. Fix the multiplication to upcast to 64 bit using an unsigned long long specifier on the multiplier. While we're here, initialise the two integer class members in the constructor initialiser list. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/timer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp index b5212ba26869..306825fde3c0 100644 --- a/src/libcamera/timer.cpp +++ b/src/libcamera/timer.cpp @@ -36,6 +36,7 @@ namespace libcamera { * \brief Construct a timer */ Timer::Timer() + : interval_(0), deadline_(0) { } @@ -51,7 +52,7 @@ void Timer::start(unsigned int msec) clock_gettime(CLOCK_MONOTONIC, &tp); interval_ = msec; - deadline_ = tp.tv_sec * 1000000000ULL + tp.tv_nsec + msec * 1000000; + deadline_ = tp.tv_sec * 1000000000ULL + tp.tv_nsec + msec * 1000000ULL; LOG(Debug) << "Starting timer " << this << " with interval " << msec << ": deadline " << deadline_; From patchwork Thu Jan 17 20:20:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 260 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 EFC4060CA0 for ; Thu, 17 Jan 2019 21:20:49 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E750558; Thu, 17 Jan 2019 21:20:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1547756449; bh=Ovaadbu20ctBxwhPphEykrE8yWk+xYxrxdgU8sbZ7rU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jm2BR1vhUq0n8Qs+eatHeOB4zThjIY4xI5WWmtZCiDD3xhFt4cc+4VaMl71FDCWG0 w3CzHKwSRezXoBXue2+ehRJZyWY7HWj/cTmnbNCehfoptdqMdaE323i9PMmcx1bZTY p0sXd/PCVQxs2rO12K+yUdUXgH9AKmPG7glFnYys= From: Kieran Bingham To: LibCamera Devel Date: Thu, 17 Jan 2019 20:20:42 +0000 Message-Id: <20190117202043.21420-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> References: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> Subject: [libcamera-devel] [PATCH 4/5] libcamera: log: Fix coding style warnings 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: Thu, 17 Jan 2019 20:20:50 -0000 The checkstyle utility highlights some minor warnings against the logger implementation. Fix these up. Fixes: edbd2059d8a4 ("libcamera: Add initial logger") Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/log.h | 6 +++--- src/libcamera/log.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h index c1af3741ffee..cc3f9404a3d4 100644 --- a/src/libcamera/include/log.h +++ b/src/libcamera/include/log.h @@ -23,11 +23,11 @@ class LogMessage { public: LogMessage(const char *fileName, unsigned int line, - LogSeverity severity); - LogMessage(const LogMessage&) = delete; + LogSeverity severity); + LogMessage(const LogMessage &) = delete; ~LogMessage(); - std::ostream& stream() { return msgStream; } + std::ostream &stream() { return msgStream; } private: std::ostringstream msgStream; diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp index 9b2ae1bac8c8..74cba383363d 100644 --- a/src/libcamera/log.cpp +++ b/src/libcamera/log.cpp @@ -66,7 +66,7 @@ namespace libcamera { static const char *log_severity_name(LogSeverity severity) { - static const char * const names[] = { + static const char *const names[] = { " DBG", " INFO", " WARN", From patchwork Thu Jan 17 20:20:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 261 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 48C8760CA7 for ; Thu, 17 Jan 2019 21:20:50 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DA56B53E; Thu, 17 Jan 2019 21:20:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1547756450; bh=taH8XZ+Akjmc/XaapHImI4FqH2AEX70rZxb043cKytg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ecGsyjfc3z9nd8KGpAkM0V0Ot/KsrhcCnSOQzH/nwIWTpj6bdUvT1Vbww6Mde6ROS tBYKFuHhveaZzLWHAIVFKKz/0jChl0T1gdzPhEVcKVKOnjlkE9r8oi1SvyQf26lPDq VjYOdgcitToODL/d20T92LadIeIwLwkZJ7ayXskg= From: Kieran Bingham To: LibCamera Devel Date: Thu, 17 Jan 2019 20:20:43 +0000 Message-Id: <20190117202043.21420-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> References: <20190117202043.21420-1-kieran.bingham@ideasonboard.com> Subject: [libcamera-devel] [PATCH 5/5] libcamera: event_dispatcher_poll: Fix trivial spelling 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: Thu, 17 Jan 2019 20:20:50 -0000 Correct the spelling of 'notifiers'. Fixes: 8356f8a6ab87 ("libcamera: Add a poll-based event dispatcher") Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- 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 69edfcbf2725..2072ae0aa3da 100644 --- a/src/libcamera/event_dispatcher_poll.cpp +++ b/src/libcamera/event_dispatcher_poll.cpp @@ -146,7 +146,7 @@ void EventDispatcherPoll::processEvents() << timeout.tv_nsec; } - /* Wait for events and process notifers and timers. */ + /* Wait for events and process notifiers and timers. */ ret = ppoll(pollfds.data(), pollfds.size(), nextTimer ? &timeout : nullptr, nullptr); if (ret < 0) {