From patchwork Sun Apr 28 23:12:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1123 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E427600EA for ; Mon, 29 Apr 2019 01:12:57 +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 8A8EF2D1 for ; Mon, 29 Apr 2019 01:12:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556493175; bh=1CoGRqIoVWa2ucqUqKUbm261ywRQxBorhNA8j5RmAzw=; h=From:To:Subject:Date:From; b=mlWyKcuzBLRZuMJjj+SdrILqI2L6MTdwYhIvPd04aq1Cw+JnsR57DCB1pJKeJc6Sd fWCSko9+71jPotYMsuxOnhz4AWDrCWlbimskWQAtfGrelv3iH48PvTvZ6LDqJAUxLP MSOIy17G0zzjLj6LihOfLE3sOCQtAiGfrJd9ajGE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Apr 2019 02:12:37 +0300 Message-Id: <20190428231238.30547-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: Don't ignore the return value of read() and write() 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: Sun, 28 Apr 2019 23:12:57 -0000 The glibc read() and write() functions are defined with the __warn_unused_result__ attribute when using FORTIFY_SOURCE. Don't ignore their return value. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/event_dispatcher_poll.cpp | 8 ++++++-- test/event.cpp | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libcamera/event_dispatcher_poll.cpp b/src/libcamera/event_dispatcher_poll.cpp index 1f0f352a8e0a..2621b7d96b1e 100644 --- a/src/libcamera/event_dispatcher_poll.cpp +++ b/src/libcamera/event_dispatcher_poll.cpp @@ -162,7 +162,9 @@ void EventDispatcherPoll::processEvents() void EventDispatcherPoll::interrupt() { uint64_t value = 1; - write(eventfd_, &value, sizeof(value)); + ssize_t ret = write(eventfd_, &value, sizeof(value)); + if (ret < 0) + LOG(Event, Error) << "Failed to interrupt event dispatcher"; } short EventDispatcherPoll::EventNotifierSetPoll::events() const @@ -214,7 +216,9 @@ void EventDispatcherPoll::processInterrupt(const struct pollfd &pfd) return; uint64_t value; - read(eventfd_, &value, sizeof(value)); + ssize_t ret = read(eventfd_, &value, sizeof(value)); + if (ret < 0) + LOG(Event, Error) << "Failed to process interrupt"; } void EventDispatcherPoll::processNotifiers(const std::vector &pollfds) diff --git a/test/event.cpp b/test/event.cpp index 52bc0c7e77f5..9bd876153a18 100644 --- a/test/event.cpp +++ b/test/event.cpp @@ -38,6 +38,7 @@ protected: EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); std::string data("H2G2"); Timer timeout; + ssize_t ret; EventNotifier readNotifier(pipefd_[0], EventNotifier::Read); readNotifier.activated.connect(this, &EventTest::readReady); @@ -46,7 +47,11 @@ protected: memset(data_, 0, sizeof(data_)); size_ = 0; - write(pipefd_[1], data.data(), data.size()); + ret = write(pipefd_[1], data.data(), data.size()); + if (ret < 0) { + cout << "Pipe write failed" << endl; + return TestFail; + } timeout.start(100); dispatcher->processEvents(); @@ -73,7 +78,11 @@ protected: notified_ = false; readNotifier.setEnabled(false); - write(pipefd_[1], data.data(), data.size()); + ret = write(pipefd_[1], data.data(), data.size()); + if (ret < 0) { + cout << "Pipe write failed" << endl; + return TestFail; + } timeout.start(100); dispatcher->processEvents(); From patchwork Sun Apr 28 23:12:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1124 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E7C5600EE for ; Mon, 29 Apr 2019 01:12:57 +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 3988A2DF for ; Mon, 29 Apr 2019 01:12:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1556493177; bh=PWez/3Rqpyn8PNwBUDhIyo8JwZkYMNT6QDU3kq6HlzM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uQ8AsPydsCIR6EwuLdPK369gRZcvk5s5spRUckf/J5FhjIOar09BFeaqPxEag67xi lh8Z1QxCbnEth3auqkOl49UVDGcWmrV0NLmcug+PAIkn3GB7yn97uc9hgQLU9ugbob /EsulHBu7j9xs41BHHZqoBiQeTdZoO7SLXgszWug= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Apr 2019 02:12:38 +0300 Message-Id: <20190428231238.30547-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190428231238.30547-1-laurent.pinchart@ideasonboard.com> References: <20190428231238.30547-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: Use compile optimisation by default 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: Sun, 28 Apr 2019 23:12:57 -0000 Set the compiler optimisation level to 2 by default. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index d272ff33b100..a11a1e4c238e 100644 --- a/meson.build +++ b/meson.build @@ -5,6 +5,7 @@ project('libcamera', 'c', 'cpp', 'werror=true', 'warning_level=2', 'cpp_std=c++11', + 'optimization=2', ], license : 'LGPL 2.1+')