From patchwork Thu Oct 22 13:56:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10199 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 939B2C3D3C for ; Thu, 22 Oct 2020 13:56:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 543BE61462; Thu, 22 Oct 2020 15:56:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NO6Hv9DR"; dkim-atps=neutral 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 19701610B6 for ; Thu, 22 Oct 2020 15:56:10 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 79A22A43; Thu, 22 Oct 2020 15:56:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1603374969; bh=/UwFBQMbTYwsBkPVdG7FRyJUA21BDFfVyGH/w41K6hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NO6Hv9DR83Vi0rgcFZNerLil9ncFRxKxR177adAQV8AxnJQ69wi14V48sV2+DrGrR H5LFFKLT7iqoYwVdWu3zeblpLgHkODl+dbE4ZdcAQiOZfsJzkBAifNDgOOIUx5/2+f bArW4ysWSLJx3lT4I/VMAtzNzPeNndAtdbv8dbck= From: Kieran Bingham To: libcamera devel Date: Thu, 22 Oct 2020 14:56:01 +0100 Message-Id: <20201022135605.614240-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> References: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] libcamera: Provide class.h 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Provide a public header to define helpers for class definitions. This initially implements macros to clearly define the deletion of copy/move/assignment constructors/operators for classes to restrict their capabilities explicitly. Signed-off-by: Kieran Bingham --- include/libcamera/class.h | 35 +++++++++++++++++++++++++++++++++++ include/libcamera/meson.build | 1 + 2 files changed, 36 insertions(+) create mode 100644 include/libcamera/class.h diff --git a/include/libcamera/class.h b/include/libcamera/class.h new file mode 100644 index 000000000000..adcfa8860957 --- /dev/null +++ b/include/libcamera/class.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * class.h - class helpers + */ +#ifndef __LIBCAMERA_CLASS_H__ +#define __LIBCAMERA_CLASS_H__ + +/** + * \brief Delete the copy constructor and assignment operator. + */ +#define DELETE_COPY_AND_ASSIGN(klass) \ + /* copy constructor. */ \ + klass(const klass &) = delete; \ + /* copy assignment operator. */ \ + klass &operator=(const klass &) = delete + +/** + * \brief Delete the move construtor and assignment operator. + */ +#define DELETE_MOVE_AND_ASSIGN(klass) \ + /* move constructor. */ \ + klass(klass &&) = delete; \ + /* move assignment operator. */ \ + klass &operator=(klass &&) = delete + +/** + * \brief Delete all copy and move constructors, and assignment operators. + */ +#define DELETE_COPY_MOVE_AND_ASSIGN(klass) \ + DELETE_COPY_AND_ASSIGN(klass); \ + DELETE_MOVE_AND_ASSIGN(klass) + +#endif /* __LIBCAMERA_CLASS_H__ */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 3d5fc70134ad..b3363a6f735b 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -5,6 +5,7 @@ libcamera_public_headers = files([ 'buffer.h', 'camera.h', 'camera_manager.h', + 'class.h', 'controls.h', 'event_dispatcher.h', 'event_notifier.h', From patchwork Thu Oct 22 13:56:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10200 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id BE87FC3D3C for ; Thu, 22 Oct 2020 13:56:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9A29E6146E; Thu, 22 Oct 2020 15:56:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aoq3fpbg"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C329610B6 for ; Thu, 22 Oct 2020 15:56:10 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1017453; Thu, 22 Oct 2020 15:56:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1603374970; bh=nDYTPfi/m7qecYLzCqIBaQXRGAFsD4RyGR2LgJiX1Hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aoq3fpbg90skWnIj41NOeu5tF44x3aWEX5dz6fKRrNd5DpIidvUflnA+81P0exzTC qMPICaYFCw5lVbkCDolV3L/wfjrtLEKBpEUfgnbB8ox/LEibM1WIOJsMO45e+5Jvgo 2UcBp37/5yzonDGqa/y9yxeZvvrVnGZHLH7ZsJBE= From: Kieran Bingham To: libcamera devel Date: Thu, 22 Oct 2020 14:56:02 +0100 Message-Id: <20201022135605.614240-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> References: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] libcamera: buffer: Utilise DELETE_COPY_MOVE_AND_ASSIGN 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/buffer.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index a26c8927d37a..42a20a387781 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -10,6 +10,7 @@ #include #include +#include #include namespace libcamera { @@ -43,12 +44,6 @@ public: FrameBuffer(const std::vector &planes, unsigned int cookie = 0); - FrameBuffer(const FrameBuffer &) = delete; - FrameBuffer(FrameBuffer &&) = delete; - - FrameBuffer &operator=(const FrameBuffer &) = delete; - FrameBuffer &operator=(FrameBuffer &&) = delete; - const std::vector &planes() const { return planes_; } Request *request() const { return request_; } @@ -57,7 +52,10 @@ public: unsigned int cookie() const { return cookie_; } void setCookie(unsigned int cookie) { cookie_ = cookie; } + private: + DELETE_COPY_MOVE_AND_ASSIGN(FrameBuffer); + friend class Request; /* Needed to update request_. */ friend class V4L2VideoDevice; /* Needed to update metadata_. */ From patchwork Thu Oct 22 13:56:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10201 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 36013C3D3C for ; Thu, 22 Oct 2020 13:56:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 04B8061454; Thu, 22 Oct 2020 15:56:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nxJflIFB"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 522E16145E for ; Thu, 22 Oct 2020 15:56:11 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B1FB6A43; Thu, 22 Oct 2020 15:56:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1603374970; bh=cIbVd7dh1s4WlnHThYctC8seCrPnYhJyU/p31yBgpjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nxJflIFBXZCLfui/KiwTT5/ZUh9hZrnnfCWDvl+Q20pN8gks1LoFiqCnBoB42AqzI nysGF22izx43aEW3XaxRkKGzhWvVrilFmbOb38WTfDWSIrSKQu2KWmDLAjipebMtDP dGc0Ku7iHnn8kUBTsJ6VwtlXtrw1EuS+8BiXQZEo= From: Kieran Bingham To: libcamera devel Date: Thu, 22 Oct 2020 14:56:03 +0100 Message-Id: <20201022135605.614240-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> References: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] libcamera: media_object: Utilise DELETE_COPY_AND_ASSIGN 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Convert MediaLink, MediaPad, and MediaEntity to declare DELETE_COPY_AND_ASSIGN. These classes already deleted their copy constructor but not the assignment operator. Utilising the DELETE_COPY_AND_ASSIGN prevents all copying of these classes. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/internal/media_object.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h index be6fb8961349..f467883072d2 100644 --- a/include/libcamera/internal/media_object.h +++ b/include/libcamera/internal/media_object.h @@ -12,6 +12,8 @@ #include +#include + namespace libcamera { class MediaDevice; @@ -50,7 +52,7 @@ private: MediaLink(const struct media_v2_link *link, MediaPad *source, MediaPad *sink); - MediaLink(const MediaLink &) = delete; + DELETE_COPY_AND_ASSIGN(MediaLink); ~MediaLink() {} MediaPad *source_; @@ -72,7 +74,7 @@ private: friend class MediaDevice; MediaPad(const struct media_v2_pad *pad, MediaEntity *entity); - MediaPad(const MediaPad &) = delete; + DELETE_COPY_AND_ASSIGN(MediaPad); ~MediaPad(); unsigned int index_; @@ -104,7 +106,7 @@ private: MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity, unsigned int major = 0, unsigned int minor = 0); - MediaEntity(const MediaEntity &) = delete; + DELETE_COPY_AND_ASSIGN(MediaEntity); ~MediaEntity(); void addPad(MediaPad *pad); From patchwork Thu Oct 22 13:56:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10202 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AE05EC3D3C for ; Thu, 22 Oct 2020 13:56:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 729D861439; Thu, 22 Oct 2020 15:56:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rG+ZDUt0"; dkim-atps=neutral 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 823D56146A for ; Thu, 22 Oct 2020 15:56:11 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1651B53; Thu, 22 Oct 2020 15:56:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1603374971; bh=Zz3yu6VewXM5fdkFPkTDlG8Vh7jM7o2ceWV9WyieKSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rG+ZDUt0JJNhMljwdD185lQDpCWo1Zfkieh4aLbtUOcJs8apczIr7Pg0WB7UnKXUL 3WCWlKgwoAFIknXcSSwdlnD/rRvEiqcOgTXLRoz0tL2Mmk6e+jlCnEJmnV14rCFMp0 NLZhZ0p2IDp0rFKtl3GbiAYFv5sKtbpiBZjz9YVs= From: Kieran Bingham To: libcamera devel Date: Thu, 22 Oct 2020 14:56:04 +0100 Message-Id: <20201022135605.614240-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> References: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] libcamera: Utilise DELETE_COPY_AND_ASSIGN 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace existing use cases where the copy constructor and copy assignment operator are deleted with the DELETE_COPY_AND_ASSIGN statement Signed-off-by: Kieran Bingham --- include/libcamera/camera.h | 7 ++++--- include/libcamera/camera_manager.h | 5 +++-- include/libcamera/controls.h | 7 +++---- include/libcamera/framebuffer_allocator.h | 7 ++++--- include/libcamera/internal/byte_stream_buffer.h | 4 ++-- include/libcamera/internal/camera_sensor.h | 6 +++--- include/libcamera/internal/file.h | 6 +++--- include/libcamera/internal/log.h | 6 +++++- include/libcamera/internal/pipeline_handler.h | 4 ++-- include/libcamera/internal/v4l2_subdevice.h | 5 +++-- include/libcamera/internal/v4l2_videodevice.h | 6 +++--- include/libcamera/request.h | 5 +++-- 12 files changed, 38 insertions(+), 30 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 79ff8d6b67a4..a9b855bb4691 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -77,9 +78,6 @@ public: const std::string &id, const std::set &streams); - Camera(const Camera &) = delete; - Camera &operator=(const Camera &) = delete; - const std::string &id() const; Signal bufferCompleted; @@ -105,6 +103,9 @@ public: private: Camera(PipelineHandler *pipe, const std::string &id, const std::set &streams); + + DELETE_COPY_AND_ASSIGN(Camera); + ~Camera(); class Private; diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 9eb2b6f5a5f5..1442c4701432 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -24,8 +25,6 @@ class CameraManager : public Object { public: CameraManager(); - CameraManager(const CameraManager &) = delete; - CameraManager &operator=(const CameraManager &) = delete; ~CameraManager(); int start(); @@ -48,6 +47,8 @@ public: Signal> cameraRemoved; private: + DELETE_COPY_AND_ASSIGN(CameraManager); + static const std::string version_; static CameraManager *self_; diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 80944efc133a..8a84170a0293 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -218,8 +219,7 @@ public: ControlType type() const { return type_; } private: - ControlId &operator=(const ControlId &) = delete; - ControlId(const ControlId &) = delete; + DELETE_COPY_AND_ASSIGN(ControlId); unsigned int id_; std::string name_; @@ -258,8 +258,7 @@ public: } private: - Control(const Control &) = delete; - Control &operator=(const Control &) = delete; + DELETE_COPY_AND_ASSIGN(Control); }; class ControlInfo diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h index a96aaeae58ce..5c540f23f8d9 100644 --- a/include/libcamera/framebuffer_allocator.h +++ b/include/libcamera/framebuffer_allocator.h @@ -11,6 +11,8 @@ #include #include +#include + namespace libcamera { class Camera; @@ -21,9 +23,6 @@ class FrameBufferAllocator { public: FrameBufferAllocator(std::shared_ptr camera); - FrameBufferAllocator(const FrameBufferAllocator &) = delete; - FrameBufferAllocator &operator=(const FrameBufferAllocator &) = delete; - ~FrameBufferAllocator(); int allocate(Stream *stream); @@ -33,6 +32,8 @@ public: const std::vector> &buffers(Stream *stream) const; private: + DELETE_COPY_AND_ASSIGN(FrameBufferAllocator); + std::shared_ptr camera_; std::map>> buffers_; }; diff --git a/include/libcamera/internal/byte_stream_buffer.h b/include/libcamera/internal/byte_stream_buffer.h index db59577dc332..b38c026c8eeb 100644 --- a/include/libcamera/internal/byte_stream_buffer.h +++ b/include/libcamera/internal/byte_stream_buffer.h @@ -11,6 +11,7 @@ #include #include +#include #include namespace libcamera { @@ -65,8 +66,7 @@ public: } private: - ByteStreamBuffer(const ByteStreamBuffer &other) = delete; - ByteStreamBuffer &operator=(const ByteStreamBuffer &other) = delete; + DELETE_COPY_AND_ASSIGN(ByteStreamBuffer); void setOverflow(); diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index b9eba89f00fb..f03791847af2 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -41,9 +42,6 @@ public: explicit CameraSensor(const MediaEntity *entity); ~CameraSensor(); - CameraSensor(const CameraSensor &) = delete; - CameraSensor &operator=(const CameraSensor &) = delete; - int init(); const std::string &model() const { return model_; } @@ -68,6 +66,8 @@ protected: std::string logPrefix() const override; private: + DELETE_COPY_AND_ASSIGN(CameraSensor); + int generateId(); const MediaEntity *entity_; diff --git a/include/libcamera/internal/file.h b/include/libcamera/internal/file.h index 9b6d011f5e9d..00f8d49d3882 100644 --- a/include/libcamera/internal/file.h +++ b/include/libcamera/internal/file.h @@ -11,6 +11,7 @@ #include #include +#include #include namespace libcamera { @@ -34,9 +35,6 @@ public: File(); ~File(); - File(const File &) = delete; - File &operator=(const File &) = delete; - const std::string &fileName() const { return name_; } void setFileName(const std::string &name); bool exists() const; @@ -62,6 +60,8 @@ public: static bool exists(const std::string &name); private: + DELETE_COPY_AND_ASSIGN(File); + void unmapAll(); std::string name_; diff --git a/include/libcamera/internal/log.h b/include/libcamera/internal/log.h index 4b10087a4718..9e312b6605d3 100644 --- a/include/libcamera/internal/log.h +++ b/include/libcamera/internal/log.h @@ -10,6 +10,8 @@ #include #include +#include + #include "libcamera/internal/utils.h" namespace libcamera { @@ -57,7 +59,7 @@ public: LogSeverity severity); LogMessage(const char *fileName, unsigned int line, const LogCategory &category, LogSeverity severity); - LogMessage(const LogMessage &) = delete; + LogMessage(LogMessage &&); ~LogMessage(); @@ -70,6 +72,8 @@ public: const std::string msg() const { return msgStream_.str(); } private: + DELETE_COPY_AND_ASSIGN(LogMessage); + void init(const char *fileName, unsigned int line); std::ostringstream msgStream_; diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index a4e1b529c461..11a57e2f63c6 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -50,8 +51,7 @@ public: std::unique_ptr ipa_; private: - CameraData(const CameraData &) = delete; - CameraData &operator=(const CameraData &) = delete; + DELETE_COPY_AND_ASSIGN(CameraData); }; class PipelineHandler : public std::enable_shared_from_this, diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index 02ee3e914a8b..28abb9299ce9 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -10,6 +10,7 @@ #include #include +#include #include #include "libcamera/internal/formats.h" @@ -40,8 +41,6 @@ public: }; explicit V4L2Subdevice(const MediaEntity *entity); - V4L2Subdevice(const V4L2Subdevice &) = delete; - V4L2Subdevice &operator=(const V4L2Subdevice &) = delete; ~V4L2Subdevice(); int open(); @@ -67,6 +66,8 @@ protected: std::string logPrefix() const override; private: + DELETE_COPY_AND_ASSIGN(V4L2Subdevice); + std::vector enumPadCodes(unsigned int pad); std::vector enumPadSizes(unsigned int pad, unsigned int code); diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 53f6a2d5515b..40d6499fce75 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -172,11 +173,8 @@ public: explicit V4L2VideoDevice(const std::string &deviceNode); explicit V4L2VideoDevice(const MediaEntity *entity); - V4L2VideoDevice(const V4L2VideoDevice &) = delete; ~V4L2VideoDevice(); - V4L2VideoDevice &operator=(const V4L2VideoDevice &) = delete; - int open(); int open(int handle, enum v4l2_buf_type type); void close(); @@ -219,6 +217,8 @@ protected: std::string logPrefix() const override; private: + DELETE_COPY_AND_ASSIGN(V4L2VideoDevice); + int getFormatMeta(V4L2DeviceFormat *format); int trySetFormatMeta(V4L2DeviceFormat *format, bool set); diff --git a/include/libcamera/request.h b/include/libcamera/request.h index 655b1324bae8..4a34ecddc16a 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -39,8 +40,6 @@ public: using BufferMap = std::map; Request(Camera *camera, uint64_t cookie = 0); - Request(const Request &) = delete; - Request &operator=(const Request &) = delete; ~Request(); void reuse(ReuseFlag flags = Default); @@ -57,6 +56,8 @@ public: bool hasPendingBuffers() const { return !pending_.empty(); } private: + DELETE_COPY_AND_ASSIGN(Request); + friend class PipelineHandler; void complete(); From patchwork Thu Oct 22 13:56:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10203 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2833AC3D3C for ; Thu, 22 Oct 2020 13:56:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ED20B6145A; Thu, 22 Oct 2020 15:56:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L3e9e8xd"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B809D61478 for ; Thu, 22 Oct 2020 15:56:11 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5AEFA17C5; Thu, 22 Oct 2020 15:56:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1603374971; bh=aqBQr4hkBETqFM9cnszpdq/GoQiskDhazGi/WzvNye8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3e9e8xdYWXtO460M2o3jBS9dr8+IqgtkC/6MhJUa1WR4hXv2VBN/4lv0iIwY6f2t QpwptO1/DF7c57Sli+0UWmqIqFF3P5NYgdDBh3/i15vbk9ZHewkB2V/26ws4SA1izi L8yWrANFmwpOheli4KeaxXw/tuzLN5ffnd2TT6iY= From: Kieran Bingham To: libcamera devel Date: Thu, 22 Oct 2020 14:56:05 +0100 Message-Id: <20201022135605.614240-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> References: <20201022135605.614240-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] libcamera: MappedBuffer: Delete copy and assignment 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Prevent copying and assignment of MappedBuffer types, which could invoke unmapping or mapped memory. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/internal/buffer.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/libcamera/internal/buffer.h b/include/libcamera/internal/buffer.h index b7b0173f93f5..8c7126482b95 100644 --- a/include/libcamera/internal/buffer.h +++ b/include/libcamera/internal/buffer.h @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -34,6 +35,9 @@ protected: int error_; std::vector maps_; + +private: + DELETE_COPY_AND_ASSIGN(MappedBuffer); }; class MappedFrameBuffer : public MappedBuffer