[{"id":33132,"web_url":"https://patchwork.libcamera.org/comment/33132/","msgid":"<q5vaw3iticf3a6qwfnmo6njywg2zg5yghyj57zpltykbkcns4v@kmhyn3q33vnc>","date":"2025-01-22T09:03:13","subject":"Re: [RFC PATCH v2 02/16] apps: common: event_loop: Disable copy/move","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Tue, Jan 14, 2025 at 06:21:56PM +0000, Barnabás Pőcze wrote:\n> The compiler generated functions are not appropriate, so\n> delete the copy/move constructor/assignment to avoid\n> potential issues.\n>\n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n\nThe class has this member\n\tstd::list<std::unique_ptr<Event>> events_;\n\nIs there a copy constructor generated for the class even if\nunique_ptr<> do not provide one ?\n\n> ---\n>  src/apps/common/event_loop.h | 5 +++++\n>  1 file changed, 5 insertions(+)\n>\n> diff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h\n> index d7d012c76..4e8dd0a46 100644\n> --- a/src/apps/common/event_loop.h\n> +++ b/src/apps/common/event_loop.h\n> @@ -13,6 +13,8 @@\n>  #include <memory>\n>  #include <mutex>\n>\n> +#include <libcamera/base/class.h>\n> +\n>  #include <event2/util.h>\n>\n>  struct event_base;\n> @@ -43,8 +45,11 @@ public:\n>  \t\t\t   std::function<void()> &&handler);\n>\n>  private:\n> +\tLIBCAMERA_DISABLE_COPY_AND_MOVE(EventLoop)\n> +\n>  \tstruct Event {\n>  \t\tEvent(std::function<void()> &&callback);\n> +\t\tLIBCAMERA_DISABLE_COPY_AND_MOVE(Event)\n>  \t\t~Event();\n>\n>  \t\tstatic void dispatch(int fd, short events, void *arg);\n> --\n> 2.48.0\n>\n>","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 3C0E5C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Jan 2025 09:03:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3ADD26855A;\n\tWed, 22 Jan 2025 10:03:19 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61C2768551\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jan 2025 10:03:17 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A369520;\n\tWed, 22 Jan 2025 10:02:14 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"pHNaO6z/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1737536534;\n\tbh=gxzm3nKhg8LeYRQBDF1K4RrRD4VdOE/hXfu23iH1v8c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=pHNaO6z/LTV2gzhgfa3aCFevLD5HFbMcIcqUKEebPtNBovyZfE+sbubZVeUXhQLcZ\n\tv/UKNAPk3QCqrCYdv2HmscaM29z+Ug+JN+XMJBdFD2csGiki6RPFeHK6EhDj6J7sEG\n\tO8S/ah3UgRC+V1Pzrh4fAMwjoRJEu1od1fHiybm8=","Date":"Wed, 22 Jan 2025 10:03:13 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v2 02/16] apps: common: event_loop: Disable copy/move","Message-ID":"<q5vaw3iticf3a6qwfnmo6njywg2zg5yghyj57zpltykbkcns4v@kmhyn3q33vnc>","References":"<20250114182143.1773762-1-pobrn@protonmail.com>\n\t<20250114182143.1773762-3-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250114182143.1773762-3-pobrn@protonmail.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33149,"web_url":"https://patchwork.libcamera.org/comment/33149/","msgid":"<ToM-z0R9PGzsV8FjNvKe4GP4xR9SkgURDDaEoOnFFiWlgZGOXLJYEbktv_VucJQcEHVkVwcHWZYAuSxUWVRWx4-ATmB0uy4tlfkNHlVSOpM=@protonmail.com>","date":"2025-01-24T09:23:47","subject":"Re: [RFC PATCH v2 02/16] apps: common: event_loop: Disable copy/move","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"Hi\n\n\n2025. január 22., szerda 10:03 keltezéssel, Jacopo Mondi <jacopo.mondi@ideasonboard.com> írta:\n\n> Hi Barnabás\n> \n> On Tue, Jan 14, 2025 at 06:21:56PM +0000, Barnabás Pőcze wrote:\n> > The compiler generated functions are not appropriate, so\n> > delete the copy/move constructor/assignment to avoid\n> > potential issues.\n> >\n> > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> \n> The class has this member\n> \tstd::list<std::unique_ptr<Event>> events_;\n> \n> Is there a copy constructor generated for the class even if\n> unique_ptr<> do not provide one ?\n\nThat list would indeed cause the copy constructor/assignment to be deleted,\nhowever, move constructor/assignment would still be generated, which would\nbe incorrect since the owning `event_base` pointer is stored in a raw pointer.\nHowever, the class has an `std::mutex` member, so there are in fact no copy/move\nconstructors/assignment operators defined by default.\n\nSo this change does not really change much, my bad, this can be probably be ignored.\nNonetheless, I have run into at least one situation in libcamera where a move\nconstructor was defined by the compiler but semantically it was wrong. Specifically,\nit was `EventNotifier`; I am wondering if `Object` should disable copy/move altogether.\n\nIn any case, I'd support it if libcamera would enforce the *rule of 0/5* more strictly.\n( https://en.cppreference.com/w/cpp/language/rule_of_three )\n\n\nRegards,\nBarnabás Pőcze\n\n> \n> > ---\n> >  src/apps/common/event_loop.h | 5 +++++\n> >  1 file changed, 5 insertions(+)\n> >\n> > diff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h\n> > index d7d012c76..4e8dd0a46 100644\n> > --- a/src/apps/common/event_loop.h\n> > +++ b/src/apps/common/event_loop.h\n> > @@ -13,6 +13,8 @@\n> >  #include <memory>\n> >  #include <mutex>\n> >\n> > +#include <libcamera/base/class.h>\n> > +\n> >  #include <event2/util.h>\n> >\n> >  struct event_base;\n> > @@ -43,8 +45,11 @@ public:\n> >  \t\t\t   std::function<void()> &&handler);\n> >\n> >  private:\n> > +\tLIBCAMERA_DISABLE_COPY_AND_MOVE(EventLoop)\n> > +\n> >  \tstruct Event {\n> >  \t\tEvent(std::function<void()> &&callback);\n> > +\t\tLIBCAMERA_DISABLE_COPY_AND_MOVE(Event)\n> >  \t\t~Event();\n> >\n> >  \t\tstatic void dispatch(int fd, short events, void *arg);\n> > --\n> > 2.48.0\n> >\n> >\n>","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 B9A31C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jan 2025 09:23:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 67E856855C;\n\tFri, 24 Jan 2025 10:23:55 +0100 (CET)","from mail-40134.protonmail.ch (mail-40134.protonmail.ch\n\t[185.70.40.134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6747A68506\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jan 2025 10:23:54 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"Vv9Zaqoi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1737710633; x=1737969833;\n\tbh=qKYxFEPMBcnY73ArD6yu2Bi+UAsQ2gZeVvJIIGCB7rw=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=Vv9Zaqoic8BiowzfDgnibcCcf3jwM8Lk6Yf7yW+E1AYyPulXMcUMRyRZ3wd3GS+Hz\n\t7lu1TFV1pw5gjs34mbM137U9b9WsGUnncm2NQf8EQTjYCghKP2HfxTLj1/g8lu76At\n\taAC8w3ziWK6Oc7zKQEfY/0PZwxA/cbAtxxUTsc2PD363aIO2eJtaFJcFKfKUDfurgk\n\t6LaeeHEaEqpayTilmZM4XM3uHZbfFyIg7oKujGiop1NtyvSpJs6UOP24PH/yQXcKCk\n\tWGzafgnnjT3TvXiqmFql6H0YJaUgCo9LulNYcaNg3Jx9p9tDcro2jfmET++T6FH39a\n\twInTadrno3Csw==","Date":"Fri, 24 Jan 2025 09:23:47 +0000","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v2 02/16] apps: common: event_loop: Disable copy/move","Message-ID":"<ToM-z0R9PGzsV8FjNvKe4GP4xR9SkgURDDaEoOnFFiWlgZGOXLJYEbktv_VucJQcEHVkVwcHWZYAuSxUWVRWx4-ATmB0uy4tlfkNHlVSOpM=@protonmail.com>","In-Reply-To":"<q5vaw3iticf3a6qwfnmo6njywg2zg5yghyj57zpltykbkcns4v@kmhyn3q33vnc>","References":"<20250114182143.1773762-1-pobrn@protonmail.com>\n\t<20250114182143.1773762-3-pobrn@protonmail.com>\n\t<q5vaw3iticf3a6qwfnmo6njywg2zg5yghyj57zpltykbkcns4v@kmhyn3q33vnc>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"f1b9cc068ae2865ef8f992ca3a63791602fe9cc2","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33151,"web_url":"https://patchwork.libcamera.org/comment/33151/","msgid":"<vo2pgz6rzgtxblgup55mbbxtnjhxbag7x6prdq3oc2mddu6tte@sn5xj6k773pp>","date":"2025-01-24T11:17:42","subject":"Re: [RFC PATCH v2 02/16] apps: common: event_loop: Disable copy/move","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Fri, Jan 24, 2025 at 09:23:47AM +0000, Barnabás Pőcze wrote:\n> Hi\n>\n>\n> 2025. január 22., szerda 10:03 keltezéssel, Jacopo Mondi <jacopo.mondi@ideasonboard.com> írta:\n>\n> > Hi Barnabás\n> >\n> > On Tue, Jan 14, 2025 at 06:21:56PM +0000, Barnabás Pőcze wrote:\n> > > The compiler generated functions are not appropriate, so\n> > > delete the copy/move constructor/assignment to avoid\n> > > potential issues.\n> > >\n> > > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> >\n> > The class has this member\n> > \tstd::list<std::unique_ptr<Event>> events_;\n> >\n> > Is there a copy constructor generated for the class even if\n> > unique_ptr<> do not provide one ?\n>\n> That list would indeed cause the copy constructor/assignment to be deleted,\n> however, move constructor/assignment would still be generated, which would\n> be incorrect since the owning `event_base` pointer is stored in a raw pointer.\n> However, the class has an `std::mutex` member, so there are in fact no copy/move\n> constructors/assignment operators defined by default.\n>\n> So this change does not really change much, my bad, this can be probably be ignored.\n> Nonetheless, I have run into at least one situation in libcamera where a move\n> constructor was defined by the compiler but semantically it was wrong. Specifically,\n> it was `EventNotifier`; I am wondering if `Object` should disable copy/move altogether.\n>\n> In any case, I'd support it if libcamera would enforce the *rule of 0/5* more strictly.\n> ( https://en.cppreference.com/w/cpp/language/rule_of_three )\n\nAre you aware of any tooling that could help us detecting which\nclasses would need attention ?\n\n>\n>\n> Regards,\n> Barnabás Pőcze\n>\n> >\n> > > ---\n> > >  src/apps/common/event_loop.h | 5 +++++\n> > >  1 file changed, 5 insertions(+)\n> > >\n> > > diff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h\n> > > index d7d012c76..4e8dd0a46 100644\n> > > --- a/src/apps/common/event_loop.h\n> > > +++ b/src/apps/common/event_loop.h\n> > > @@ -13,6 +13,8 @@\n> > >  #include <memory>\n> > >  #include <mutex>\n> > >\n> > > +#include <libcamera/base/class.h>\n> > > +\n> > >  #include <event2/util.h>\n> > >\n> > >  struct event_base;\n> > > @@ -43,8 +45,11 @@ public:\n> > >  \t\t\t   std::function<void()> &&handler);\n> > >\n> > >  private:\n> > > +\tLIBCAMERA_DISABLE_COPY_AND_MOVE(EventLoop)\n> > > +\n> > >  \tstruct Event {\n> > >  \t\tEvent(std::function<void()> &&callback);\n> > > +\t\tLIBCAMERA_DISABLE_COPY_AND_MOVE(Event)\n> > >  \t\t~Event();\n> > >\n> > >  \t\tstatic void dispatch(int fd, short events, void *arg);\n> > > --\n> > > 2.48.0\n> > >\n> > >\n> >","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 6AD19C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jan 2025 11:17:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8156F6855D;\n\tFri, 24 Jan 2025 12:17:47 +0100 (CET)","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 BC9CE68556\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jan 2025 12:17:45 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6A1EC465;\n\tFri, 24 Jan 2025 12:16:41 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"g68koiZl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1737717401;\n\tbh=LNFUag2PhHlP3KwLsGSjICh0LlKulQDfdAJbh6R5tlA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=g68koiZlvc/t3vHE6fcArBgaZu/iLJAZ1gxARCJl+WER4u2E/MhNxTE0BMv5e4KDp\n\tuHJb48go9ayBtUejxtVJzcx7g2oBaDTXsMeQLLTEq1oUNv55wPUE86uNTR5ZY3VidA\n\tEsLR/2tVqLeJt6e6FO9sIJDgAWbwpY4FmecmYrjU=","Date":"Fri, 24 Jan 2025 12:17:42 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v2 02/16] apps: common: event_loop: Disable copy/move","Message-ID":"<vo2pgz6rzgtxblgup55mbbxtnjhxbag7x6prdq3oc2mddu6tte@sn5xj6k773pp>","References":"<20250114182143.1773762-1-pobrn@protonmail.com>\n\t<20250114182143.1773762-3-pobrn@protonmail.com>\n\t<q5vaw3iticf3a6qwfnmo6njywg2zg5yghyj57zpltykbkcns4v@kmhyn3q33vnc>\n\t<ToM-z0R9PGzsV8FjNvKe4GP4xR9SkgURDDaEoOnFFiWlgZGOXLJYEbktv_VucJQcEHVkVwcHWZYAuSxUWVRWx4-ATmB0uy4tlfkNHlVSOpM=@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<ToM-z0R9PGzsV8FjNvKe4GP4xR9SkgURDDaEoOnFFiWlgZGOXLJYEbktv_VucJQcEHVkVwcHWZYAuSxUWVRWx4-ATmB0uy4tlfkNHlVSOpM=@protonmail.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33153,"web_url":"https://patchwork.libcamera.org/comment/33153/","msgid":"<RDaz4y3St0MMFjfM6u2ehLWApVV2NWeAbGkACEjoGpkfaxW3geEwi7XSnCYBNc8LTnjf-5Z2VuMrXjqilr3mMy6cD-ndnoPE37LNTvg6LwU=@protonmail.com>","date":"2025-01-24T11:25:44","subject":"Re: [RFC PATCH v2 02/16] apps: common: event_loop: Disable copy/move","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"2025. január 24., péntek 12:17 keltezéssel, Jacopo Mondi <jacopo.mondi@ideasonboard.com> írta:\n\n> Hi Barnabás\n> \n> On Fri, Jan 24, 2025 at 09:23:47AM +0000, Barnabás Pőcze wrote:\n> > Hi\n> >\n> >\n> > 2025. január 22., szerda 10:03 keltezéssel, Jacopo Mondi <jacopo.mondi@ideasonboard.com> írta:\n> >\n> > > Hi Barnabás\n> > >\n> > > On Tue, Jan 14, 2025 at 06:21:56PM +0000, Barnabás Pőcze wrote:\n> > > > The compiler generated functions are not appropriate, so\n> > > > delete the copy/move constructor/assignment to avoid\n> > > > potential issues.\n> > > >\n> > > > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> > >\n> > > The class has this member\n> > > \tstd::list<std::unique_ptr<Event>> events_;\n> > >\n> > > Is there a copy constructor generated for the class even if\n> > > unique_ptr<> do not provide one ?\n> >\n> > That list would indeed cause the copy constructor/assignment to be deleted,\n> > however, move constructor/assignment would still be generated, which would\n> > be incorrect since the owning `event_base` pointer is stored in a raw pointer.\n> > However, the class has an `std::mutex` member, so there are in fact no copy/move\n> > constructors/assignment operators defined by default.\n> >\n> > So this change does not really change much, my bad, this can be probably be ignored.\n> > Nonetheless, I have run into at least one situation in libcamera where a move\n> > constructor was defined by the compiler but semantically it was wrong. Specifically,\n> > it was `EventNotifier`; I am wondering if `Object` should disable copy/move altogether.\n> >\n> > In any case, I'd support it if libcamera would enforce the *rule of 0/5* more strictly.\n> > ( https://en.cppreference.com/w/cpp/language/rule_of_three )\n> \n> Are you aware of any tooling that could help us detecting which\n> classes would need attention ?\n\nclang-tidy for example: https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/special-member-functions.html\n\n\nRegards,\nBarnabás Pőcze\n\n> \n> >\n> >\n> > Regards,\n> > Barnabás Pőcze\n> >\n> > >\n> > > > ---\n> > > >  src/apps/common/event_loop.h | 5 +++++\n> > > >  1 file changed, 5 insertions(+)\n> > > >\n> > > > diff --git a/src/apps/common/event_loop.h b/src/apps/common/event_loop.h\n> > > > index d7d012c76..4e8dd0a46 100644\n> > > > --- a/src/apps/common/event_loop.h\n> > > > +++ b/src/apps/common/event_loop.h\n> > > > @@ -13,6 +13,8 @@\n> > > >  #include <memory>\n> > > >  #include <mutex>\n> > > >\n> > > > +#include <libcamera/base/class.h>\n> > > > +\n> > > >  #include <event2/util.h>\n> > > >\n> > > >  struct event_base;\n> > > > @@ -43,8 +45,11 @@ public:\n> > > >  \t\t\t   std::function<void()> &&handler);\n> > > >\n> > > >  private:\n> > > > +\tLIBCAMERA_DISABLE_COPY_AND_MOVE(EventLoop)\n> > > > +\n> > > >  \tstruct Event {\n> > > >  \t\tEvent(std::function<void()> &&callback);\n> > > > +\t\tLIBCAMERA_DISABLE_COPY_AND_MOVE(Event)\n> > > >  \t\t~Event();\n> > > >\n> > > >  \t\tstatic void dispatch(int fd, short events, void *arg);\n> > > > --\n> > > > 2.48.0\n> > > >\n> > > >\n> > >\n>","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 85C8BC322E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jan 2025 11:25:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9112B6855F;\n\tFri, 24 Jan 2025 12:25:51 +0100 (CET)","from mail-40134.protonmail.ch (mail-40134.protonmail.ch\n\t[185.70.40.134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 58DC368559\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jan 2025 12:25:50 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"Tv9RI7mL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1737717949; x=1737977149;\n\tbh=nB+66uJW9+xq5u7BeoaSTHJukCGzNH5kuGq8orTkeR8=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=Tv9RI7mLtFxHquiQQ6MKWJEKTLZjEXyE8U8SK+HYVokTbxL1L7RhlkGPWzQKD7WXn\n\t4904Mc61JQ9GHqZz8QJg7u+wrIqiPabnH2P31j0oL58ZpG2IYgnhv6gTK1P8LjDGM9\n\te1ONefOTgaKnTVUhK4UT4mAy1x4v9c5aQdW6o6cu56Oex6k2GfldOmCL7uFidr6h4C\n\tSuMnJqxHfjZ9gx75BLpMJBp6NwoF/Rvvzb+Ezv5gD8kFRtRJ9B/aZDqGGjQ5vmL3P8\n\t8IFnStVUOAZtH8XUQofgZD4oAn/Ves152793+jPLOUI7aQ+FJe+1hWkY+Mz25vNa1H\n\tWgo54NbQAQNCA==","Date":"Fri, 24 Jan 2025 11:25:44 +0000","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v2 02/16] apps: common: event_loop: Disable copy/move","Message-ID":"<RDaz4y3St0MMFjfM6u2ehLWApVV2NWeAbGkACEjoGpkfaxW3geEwi7XSnCYBNc8LTnjf-5Z2VuMrXjqilr3mMy6cD-ndnoPE37LNTvg6LwU=@protonmail.com>","In-Reply-To":"<vo2pgz6rzgtxblgup55mbbxtnjhxbag7x6prdq3oc2mddu6tte@sn5xj6k773pp>","References":"<20250114182143.1773762-1-pobrn@protonmail.com>\n\t<20250114182143.1773762-3-pobrn@protonmail.com>\n\t<q5vaw3iticf3a6qwfnmo6njywg2zg5yghyj57zpltykbkcns4v@kmhyn3q33vnc>\n\t<ToM-z0R9PGzsV8FjNvKe4GP4xR9SkgURDDaEoOnFFiWlgZGOXLJYEbktv_VucJQcEHVkVwcHWZYAuSxUWVRWx4-ATmB0uy4tlfkNHlVSOpM=@protonmail.com>\n\t<vo2pgz6rzgtxblgup55mbbxtnjhxbag7x6prdq3oc2mddu6tte@sn5xj6k773pp>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"de88a1d08c293344b6bad7ae24aa7ccf9a1f5596","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]