[{"id":20057,"web_url":"https://patchwork.libcamera.org/comment/20057/","msgid":"<YVweZ6+Nmyzy4qvx@pendragon.ideasonboard.com>","date":"2021-10-05T09:44:07","subject":"Re: [libcamera-devel] [RFC PATCH 4/6] v4l2: Remove using namespace\n\tin header files","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Tue, Oct 05, 2021 at 04:31:12PM +0900, Hirokazu Honda wrote:\n> \"using namespace\" in a header file propagates the namespace to\n> the files including the header file. So it should be avoided.\n> This removes \"using namespace\" in header files in v4l2.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/v4l2/v4l2_camera.h         | 37 +++++++++++++++++-----------------\n>  src/v4l2/v4l2_camera_proxy.h   | 15 +++++++-------\n>  src/v4l2/v4l2_compat_manager.h |  4 +---\n>  3 files changed, 26 insertions(+), 30 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\n> index a095f4e2..e81996f2 100644\n> --- a/src/v4l2/v4l2_camera.h\n> +++ b/src/v4l2/v4l2_camera.h\n> @@ -19,41 +19,40 @@\n>  #include <libcamera/framebuffer.h>\n>  #include <libcamera/framebuffer_allocator.h>\n>  \n> -using namespace libcamera;\n> -\n>  class V4L2Camera\n>  {\n>  public:\n>  \tstruct Buffer {\n> -\t\tBuffer(unsigned int index, const FrameMetadata &data)\n> +\t\tBuffer(unsigned int index, const libcamera::FrameMetadata &data)\n>  \t\t\t: index_(index), data_(data)\n>  \t\t{\n>  \t\t}\n>  \n>  \t\tunsigned int index_;\n> -\t\tFrameMetadata data_;\n> +\t\tlibcamera::FrameMetadata data_;\n>  \t};\n>  \n> -\tV4L2Camera(std::shared_ptr<Camera> camera);\n> +\tV4L2Camera(std::shared_ptr<libcamera::Camera> camera);\n>  \t~V4L2Camera();\n>  \n> -\tint open(StreamConfiguration *streamConfig);\n> +\tint open(libcamera::StreamConfiguration *streamConfig);\n>  \tvoid close();\n>  \tvoid bind(int efd);\n>  \tvoid unbind();\n>  \n>  \tstd::vector<Buffer> completedBuffers();\n>  \n> -\tint configure(StreamConfiguration *streamConfigOut,\n> -\t\t      const Size &size, const PixelFormat &pixelformat,\n> +\tint configure(libcamera::StreamConfiguration *streamConfigOut,\n> +\t\t      const libcamera::Size &size,\n> +\t\t      const libcamera::PixelFormat &pixelformat,\n>  \t\t      unsigned int bufferCount);\n> -\tint validateConfiguration(const PixelFormat &pixelformat,\n> -\t\t\t\t  const Size &size,\n> -\t\t\t\t  StreamConfiguration *streamConfigOut);\n> +\tint validateConfiguration(const libcamera::PixelFormat &pixelformat,\n> +\t\t\t\t  const libcamera::Size &size,\n> +\t\t\t\t  libcamera::StreamConfiguration *streamConfigOut);\n>  \n>  \tint allocBuffers(unsigned int count);\n>  \tvoid freeBuffers();\n> -\tFileDescriptor getBufferFd(unsigned int index);\n> +\tlibcamera::FileDescriptor getBufferFd(unsigned int index);\n>  \n>  \tint streamOn();\n>  \tint streamOff();\n> @@ -66,24 +65,24 @@ public:\n>  \tbool isRunning();\n>  \n>  private:\n> -\tvoid requestComplete(Request *request);\n> +\tvoid requestComplete(libcamera::Request *request);\n>  \n> -\tstd::shared_ptr<Camera> camera_;\n> -\tstd::unique_ptr<CameraConfiguration> config_;\n> +\tstd::shared_ptr<libcamera::Camera> camera_;\n> +\tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n>  \n>  \tbool isRunning_;\n>  \n>  \tstd::mutex bufferLock_;\n> -\tFrameBufferAllocator *bufferAllocator_;\n> +\tlibcamera::FrameBufferAllocator *bufferAllocator_;\n>  \n> -\tstd::vector<std::unique_ptr<Request>> requestPool_;\n> +\tstd::vector<std::unique_ptr<libcamera::Request>> requestPool_;\n>  \n> -\tstd::deque<Request *> pendingRequests_;\n> +\tstd::deque<libcamera::Request *> pendingRequests_;\n>  \tstd::deque<std::unique_ptr<Buffer>> completedBuffers_;\n>  \n>  \tint efd_;\n>  \n> -\tMutex bufferMutex_;\n> +\tlibcamera::Mutex bufferMutex_;\n>  \tstd::condition_variable bufferCV_;\n>  \tunsigned int bufferAvailableCount_;\n>  };\n> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> index f1a8b61c..56a45bb7 100644\n> --- a/src/v4l2/v4l2_camera_proxy.h\n> +++ b/src/v4l2/v4l2_camera_proxy.h\n> @@ -19,14 +19,12 @@\n>  \n>  #include \"v4l2_camera.h\"\n>  \n> -using namespace libcamera;\n> -\n>  class V4L2CameraFile;\n>  \n>  class V4L2CameraProxy\n>  {\n>  public:\n> -\tV4L2CameraProxy(unsigned int index, std::shared_ptr<Camera> camera);\n> +\tV4L2CameraProxy(unsigned int index, std::shared_ptr<libcamera::Camera> camera);\n>  \n>  \tint open(V4L2CameraFile *file);\n>  \tvoid close(V4L2CameraFile *file);\n> @@ -38,8 +36,8 @@ public:\n>  private:\n>  \tbool validateBufferType(uint32_t type);\n>  \tbool validateMemoryType(uint32_t memory);\n> -\tvoid setFmtFromConfig(const StreamConfiguration &streamConfig);\n> -\tvoid querycap(std::shared_ptr<Camera> camera);\n> +\tvoid setFmtFromConfig(const libcamera::StreamConfiguration &streamConfig);\n> +\tvoid querycap(std::shared_ptr<libcamera::Camera> camera);\n>  \tint tryFormat(struct v4l2_format *arg);\n>  \tenum v4l2_priority maxPriority();\n>  \tvoid updateBuffers();\n> @@ -59,7 +57,8 @@ private:\n>  \tint vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg);\n>  \tint vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n>  \tint vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> -\tint vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, MutexLocker *locker);\n> +\tint vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> +\t\t\t libcamera::MutexLocker *locker);\n>  \tint vidioc_streamon(V4L2CameraFile *file, int *arg);\n>  \tint vidioc_streamoff(V4L2CameraFile *file, int *arg);\n>  \n> @@ -72,7 +71,7 @@ private:\n>  \tunsigned int refcount_;\n>  \tunsigned int index_;\n>  \n> -\tStreamConfiguration streamConfig_;\n> +\tlibcamera::StreamConfiguration streamConfig_;\n>  \tunsigned int bufferCount_;\n>  \tunsigned int currentBuf_;\n>  \tunsigned int sizeimage_;\n> @@ -99,7 +98,7 @@ private:\n>  \tV4L2CameraFile *owner_;\n>  \n>  \t/* This mutex is to serialize access to the proxy. */\n> -\tMutex proxyMutex_;\n> +\tlibcamera::Mutex proxyMutex_;\n>  };\n>  \n>  #endif /* __V4L2_CAMERA_PROXY_H__ */\n> diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\n> index 1ec46162..b11698cc 100644\n> --- a/src/v4l2/v4l2_compat_manager.h\n> +++ b/src/v4l2/v4l2_compat_manager.h\n> @@ -18,8 +18,6 @@\n>  \n>  #include \"v4l2_camera_proxy.h\"\n>  \n> -using namespace libcamera;\n> -\n>  class V4L2CompatManager\n>  {\n>  public:\n> @@ -64,7 +62,7 @@ private:\n>  \n>  \tFileOperations fops_;\n>  \n> -\tCameraManager *cm_;\n> +\tlibcamera::CameraManager *cm_;\n>  \n>  \tstd::vector<std::unique_ptr<V4L2CameraProxy>> proxies_;\n>  \tstd::map<int, std::shared_ptr<V4L2CameraFile>> files_;","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4E45FBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Oct 2021 09:44:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 21817691B9;\n\tTue,  5 Oct 2021 11:44:17 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D527684C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Oct 2021 11:44:16 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6463525B;\n\tTue,  5 Oct 2021 11:44:15 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"OCAQGnFn\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1633427056;\n\tbh=B+vYK69iJ+DMZ9vzTlIMCsOE0dm03SrTWW2QUM+yk5A=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OCAQGnFnIvxwyia6jLWaf3zrVMiOIeVahNOwLko8RXOeZp64DBfgi4mcvLH9ru2bV\n\t94RvVC4SHRl8EnryRElY+4Onu5KHvI7lBVDebBIvFZ23IqXC1Yl701p9ilZJ/yFz+K\n\tNjTnMlx9NUcma/0zkc7rjCZcTm2qlbbIjizsBp8o=","Date":"Tue, 5 Oct 2021 12:44:07 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YVweZ6+Nmyzy4qvx@pendragon.ideasonboard.com>","References":"<20211005073114.3997303-1-hiroh@chromium.org>\n\t<20211005073114.3997303-5-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211005073114.3997303-5-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [RFC PATCH 4/6] v4l2: Remove using namespace\n\tin header files","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]