[{"id":33479,"web_url":"https://patchwork.libcamera.org/comment/33479/","msgid":"<20250225212203.GI18866@pendragon.ideasonboard.com>","date":"2025-02-25T21:22:03","subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops without\n\texpression","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Milan,\n\nThank you for the patch.\n\nOn Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote:\n> The clang formatter removes spaces in places of empty expressions in for\n> loops.  For example, it changes\n> \n>   for (init; condition; )\n> \n> to\n> \n>   for (init; condition;)\n> \n> libcamera currently uses both the styles and we should use only one of\n> them for consistency.  Since there is apparently no option to override\n> the formatter behavior (see\n> https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove\n> the extra spaces to make the formatter happy.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n\nIt's not my favourite style, but I'm OK with it given the inconvenience\nof making it a clang-format exception.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/apps/common/options.cpp        | 2 +-\n>  src/apps/qcam/format_converter.cpp | 2 +-\n>  src/libcamera/base/object.cpp      | 2 +-\n>  src/libcamera/base/signal.cpp      | 2 +-\n>  src/libcamera/base/thread.cpp      | 2 +-\n>  src/libcamera/process.cpp          | 2 +-\n>  6 files changed, 6 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp\n> index ece268d0..cae193cc 100644\n> --- a/src/apps/common/options.cpp\n> +++ b/src/apps/common/options.cpp\n> @@ -1040,7 +1040,7 @@ void OptionsParser::usageOptions(const std::list<Option> &options,\n>  \n>  \t\tstd::cerr << std::setw(indent) << argument;\n>  \n> -\t\tfor (const char *help = option.help, *end = help; end; ) {\n> +\t\tfor (const char *help = option.help, *end = help; end;) {\n>  \t\t\tend = strchr(help, '\\n');\n>  \t\t\tif (end) {\n>  \t\t\t\tstd::cerr << std::string(help, end - help + 1);\n> diff --git a/src/apps/qcam/format_converter.cpp b/src/apps/qcam/format_converter.cpp\n> index 32123493..b025a3c7 100644\n> --- a/src/apps/qcam/format_converter.cpp\n> +++ b/src/apps/qcam/format_converter.cpp\n> @@ -249,7 +249,7 @@ void FormatConverter::convertYUVPacked(const Image *srcImage, unsigned char *dst\n>  \tdst_stride = width_ * 4;\n>  \n>  \tfor (src_y = 0, dst_y = 0; dst_y < height_; src_y++, dst_y++) {\n> -\t\tfor (src_x = 0, dst_x = 0; dst_x < width_; ) {\n> +\t\tfor (src_x = 0, dst_x = 0; dst_x < width_;) {\n>  \t\t\tcb = src[src_y * src_stride + src_x * 4 + cb_pos_];\n>  \t\t\tcr = src[src_y * src_stride + src_x * 4 + cr_pos];\n>  \n> diff --git a/src/libcamera/base/object.cpp b/src/libcamera/base/object.cpp\n> index 745d2565..37d133cc 100644\n> --- a/src/libcamera/base/object.cpp\n> +++ b/src/libcamera/base/object.cpp\n> @@ -350,7 +350,7 @@ void Object::connect(SignalBase *signal)\n>  \n>  void Object::disconnect(SignalBase *signal)\n>  {\n> -\tfor (auto iter = signals_.begin(); iter != signals_.end(); ) {\n> +\tfor (auto iter = signals_.begin(); iter != signals_.end();) {\n>  \t\tif (*iter == signal)\n>  \t\t\titer = signals_.erase(iter);\n>  \t\telse\n> diff --git a/src/libcamera/base/signal.cpp b/src/libcamera/base/signal.cpp\n> index b782e050..7876a21d 100644\n> --- a/src/libcamera/base/signal.cpp\n> +++ b/src/libcamera/base/signal.cpp\n> @@ -49,7 +49,7 @@ void SignalBase::disconnect(std::function<bool(SlotList::iterator &)> match)\n>  {\n>  \tMutexLocker locker(signalsLock);\n>  \n> -\tfor (auto iter = slots_.begin(); iter != slots_.end(); ) {\n> +\tfor (auto iter = slots_.begin(); iter != slots_.end();) {\n>  \t\tif (match(iter)) {\n>  \t\t\tObject *object = (*iter)->object();\n>  \t\t\tif (object)\n> diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp\n> index 319bfda9..646ad3cb 100644\n> --- a/src/libcamera/base/thread.cpp\n> +++ b/src/libcamera/base/thread.cpp\n> @@ -657,7 +657,7 @@ void Thread::dispatchMessages(Message::Type type)\n>  \t * the outer calls.\n>  \t */\n>  \tif (!--data_->messages_.recursion_) {\n> -\t\tfor (auto iter = messages.begin(); iter != messages.end(); ) {\n> +\t\tfor (auto iter = messages.begin(); iter != messages.end();) {\n>  \t\t\tif (!*iter)\n>  \t\t\t\titer = messages.erase(iter);\n>  \t\t\telse\n> diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp\n> index bc9833f4..68fad327 100644\n> --- a/src/libcamera/process.cpp\n> +++ b/src/libcamera/process.cpp\n> @@ -75,7 +75,7 @@ void ProcessManager::sighandler()\n>  \t\treturn;\n>  \t}\n>  \n> -\tfor (auto it = processes_.begin(); it != processes_.end(); ) {\n> +\tfor (auto it = processes_.begin(); it != processes_.end();) {\n>  \t\tProcess *process = *it;\n>  \n>  \t\tint wstatus;","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 25534BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Feb 2025 21:22:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 20F016872B;\n\tTue, 25 Feb 2025 22:22:24 +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 A8EA9686D6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Feb 2025 22:22:22 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1678982E;\n\tTue, 25 Feb 2025 22:20:55 +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=\"V3QemMFU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740518455;\n\tbh=Dh8KhuWp6VEI+xlBvpGIy1fase4tbHP6wKbMHmh0gLU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=V3QemMFUa6UMjMgRsKLCjVYB9iYyOYJVW0OTtrX0Y8h+veIwgw+pw149D0B3fz8/g\n\t9dldOynHcIXa2zfeFUxQdXRbFH5hfOzMzGlOexivy/BoTKJ9rfhgkLX3tqsyx9TSTp\n\t73zReF0feiY7lMTaQ3SOgSfo14pcOrBYbi4nx/WY=","Date":"Tue, 25 Feb 2025 23:22:03 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops without\n\texpression","Message-ID":"<20250225212203.GI18866@pendragon.ideasonboard.com>","References":"<20250225152806.22705-1-mzamazal@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250225152806.22705-1-mzamazal@redhat.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":33482,"web_url":"https://patchwork.libcamera.org/comment/33482/","msgid":"<174052524726.673606.12968336202345453139@ping.linuxembedded.co.uk>","date":"2025-02-25T23:14:07","subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops without\n\texpression","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2025-02-25 21:22:03)\n> Hi Milan,\n> \n> Thank you for the patch.\n> \n> On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote:\n> > The clang formatter removes spaces in places of empty expressions in for\n> > loops.  For example, it changes\n> > \n> >   for (init; condition; )\n> > \n> > to\n> > \n> >   for (init; condition;)\n> > \n> > libcamera currently uses both the styles and we should use only one of\n> > them for consistency.  Since there is apparently no option to override\n> > the formatter behavior (see\n> > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove\n> > the extra spaces to make the formatter happy.\n> > \n> > Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> \n> It's not my favourite style, but I'm OK with it given the inconvenience\n> of making it a clang-format exception.\n\nI remember we discussed this quite some time ago, but I'm fine with\nmaking the formatter happy - that makes all our lives easier.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > ---\n> >  src/apps/common/options.cpp        | 2 +-\n> >  src/apps/qcam/format_converter.cpp | 2 +-\n> >  src/libcamera/base/object.cpp      | 2 +-\n> >  src/libcamera/base/signal.cpp      | 2 +-\n> >  src/libcamera/base/thread.cpp      | 2 +-\n> >  src/libcamera/process.cpp          | 2 +-\n> >  6 files changed, 6 insertions(+), 6 deletions(-)\n> > \n> > diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp\n> > index ece268d0..cae193cc 100644\n> > --- a/src/apps/common/options.cpp\n> > +++ b/src/apps/common/options.cpp\n> > @@ -1040,7 +1040,7 @@ void OptionsParser::usageOptions(const std::list<Option> &options,\n> >  \n> >               std::cerr << std::setw(indent) << argument;\n> >  \n> > -             for (const char *help = option.help, *end = help; end; ) {\n> > +             for (const char *help = option.help, *end = help; end;) {\n> >                       end = strchr(help, '\\n');\n> >                       if (end) {\n> >                               std::cerr << std::string(help, end - help + 1);\n> > diff --git a/src/apps/qcam/format_converter.cpp b/src/apps/qcam/format_converter.cpp\n> > index 32123493..b025a3c7 100644\n> > --- a/src/apps/qcam/format_converter.cpp\n> > +++ b/src/apps/qcam/format_converter.cpp\n> > @@ -249,7 +249,7 @@ void FormatConverter::convertYUVPacked(const Image *srcImage, unsigned char *dst\n> >       dst_stride = width_ * 4;\n> >  \n> >       for (src_y = 0, dst_y = 0; dst_y < height_; src_y++, dst_y++) {\n> > -             for (src_x = 0, dst_x = 0; dst_x < width_; ) {\n> > +             for (src_x = 0, dst_x = 0; dst_x < width_;) {\n> >                       cb = src[src_y * src_stride + src_x * 4 + cb_pos_];\n> >                       cr = src[src_y * src_stride + src_x * 4 + cr_pos];\n> >  \n> > diff --git a/src/libcamera/base/object.cpp b/src/libcamera/base/object.cpp\n> > index 745d2565..37d133cc 100644\n> > --- a/src/libcamera/base/object.cpp\n> > +++ b/src/libcamera/base/object.cpp\n> > @@ -350,7 +350,7 @@ void Object::connect(SignalBase *signal)\n> >  \n> >  void Object::disconnect(SignalBase *signal)\n> >  {\n> > -     for (auto iter = signals_.begin(); iter != signals_.end(); ) {\n> > +     for (auto iter = signals_.begin(); iter != signals_.end();) {\n> >               if (*iter == signal)\n> >                       iter = signals_.erase(iter);\n> >               else\n> > diff --git a/src/libcamera/base/signal.cpp b/src/libcamera/base/signal.cpp\n> > index b782e050..7876a21d 100644\n> > --- a/src/libcamera/base/signal.cpp\n> > +++ b/src/libcamera/base/signal.cpp\n> > @@ -49,7 +49,7 @@ void SignalBase::disconnect(std::function<bool(SlotList::iterator &)> match)\n> >  {\n> >       MutexLocker locker(signalsLock);\n> >  \n> > -     for (auto iter = slots_.begin(); iter != slots_.end(); ) {\n> > +     for (auto iter = slots_.begin(); iter != slots_.end();) {\n> >               if (match(iter)) {\n> >                       Object *object = (*iter)->object();\n> >                       if (object)\n> > diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp\n> > index 319bfda9..646ad3cb 100644\n> > --- a/src/libcamera/base/thread.cpp\n> > +++ b/src/libcamera/base/thread.cpp\n> > @@ -657,7 +657,7 @@ void Thread::dispatchMessages(Message::Type type)\n> >        * the outer calls.\n> >        */\n> >       if (!--data_->messages_.recursion_) {\n> > -             for (auto iter = messages.begin(); iter != messages.end(); ) {\n> > +             for (auto iter = messages.begin(); iter != messages.end();) {\n> >                       if (!*iter)\n> >                               iter = messages.erase(iter);\n> >                       else\n> > diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp\n> > index bc9833f4..68fad327 100644\n> > --- a/src/libcamera/process.cpp\n> > +++ b/src/libcamera/process.cpp\n> > @@ -75,7 +75,7 @@ void ProcessManager::sighandler()\n> >               return;\n> >       }\n> >  \n> > -     for (auto it = processes_.begin(); it != processes_.end(); ) {\n> > +     for (auto it = processes_.begin(); it != processes_.end();) {\n> >               Process *process = *it;\n> >  \n> >               int wstatus;\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 2A16EBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Feb 2025 23:14:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8D64368732;\n\tWed, 26 Feb 2025 00:14:12 +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 A466B61856\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Feb 2025 00:14:10 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 03D75502;\n\tWed, 26 Feb 2025 00:12:42 +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=\"Z78EmETF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740525163;\n\tbh=wo3r+z6duUcbXfA6WwI1vzCzOX5BI/GEgZHPHPO7Lyw=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Z78EmETFjBUhBsokETslZgZz/hFvB5wjAGjH9aQApP6cTDWmAoRlgyNq2JjGqr65n\n\tdOjg3yVVUnyJjgb8YJXvmpa+KyEodt5JHV9yV92A1FYWG7+ho/fGv0mGTAK/PbHTdB\n\tEVH07WKBRgi80iGtlbteeZjGQuqWbPXHx5+5alqE=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250225212203.GI18866@pendragon.ideasonboard.com>","References":"<20250225152806.22705-1-mzamazal@redhat.com>\n\t<20250225212203.GI18866@pendragon.ideasonboard.com>","Subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops without\n\texpression","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tMilan Zamazal <mzamazal@redhat.com>","Date":"Tue, 25 Feb 2025 23:14:07 +0000","Message-ID":"<174052524726.673606.12968336202345453139@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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":33494,"web_url":"https://patchwork.libcamera.org/comment/33494/","msgid":"<Z77M7EwKCX9iOS3D@linux.intel.com>","date":"2025-02-26T08:12:28","subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops without\n\texpression","submitter":{"id":211,"url":"https://patchwork.libcamera.org/api/people/211/","name":"Stanislaw Gruszka","email":"stanislaw.gruszka@linux.intel.com"},"content":"Hi,\n\nOn Tue, Feb 25, 2025 at 11:14:07PM +0000, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2025-02-25 21:22:03)\n> > Hi Milan,\n> > \n> > Thank you for the patch.\n> > \n> > On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote:\n> > > The clang formatter removes spaces in places of empty expressions in for\n> > > loops.  For example, it changes\n> > > \n> > >   for (init; condition; )\n> > > \n> > > to\n> > > \n> > >   for (init; condition;)\n> > > \n> > > libcamera currently uses both the styles and we should use only one of\n> > > them for consistency.  Since there is apparently no option to override\n> > > the formatter behavior (see\n> > > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove\n> > > the extra spaces to make the formatter happy.\n> > > \n> > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> > \n> > It's not my favourite style, but I'm OK with it given the inconvenience\n> > of making it a clang-format exception.\n> \n> I remember we discussed this quite some time ago, but I'm fine with\n> making the formatter happy - that makes all our lives easier.\n\nBTW I had formatter issue when editing src/libcamera/v4l2_device.cpp \nIt get me changes like this:\n\n@@ -482,11 +482,12 @@ int V4L2Device::setFrameStartEnabled(bool enable)\n \tif (frameStartEnabled_ == enable)\n \t\treturn 0;\n \n-\tstruct v4l2_event_subscription event{};\n+\tstruct v4l2_event_subscription event {\n+\t};\n \tevent.type = V4L2_EVENT_FRAME_SYNC;\n \n \tunsigned long request = enable ? VIDIOC_SUBSCRIBE_EVENT\n-\t\t\t      : VIDIOC_UNSUBSCRIBE_EVENT;\n+\t\t\t\t       : VIDIOC_UNSUBSCRIBE_EVENT;\n \tint ret = ioctl(request, &event);\n \tif (enable && ret)\n \t\treturn ret;\n@@ -828,7 +829,8 @@ void V4L2Device::updateControls(ControlList *ctrls,\n  */\n void V4L2Device::eventAvailable()\n {\n-\tstruct v4l2_event event{};\n+\tstruct v4l2_event event {\n+\t};\n \tint ret = ioctl(VIDIOC_DQEVENT, &event);\n \tif (ret < 0) {\n \t\tLOG(V4L2, Error)\n@@ -850,11 +852,7 @@ void V4L2Device::eventAvailable()\n \n static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = {\n \t{ V4L2_COLORSPACE_RAW, ColorSpace::Raw },\n-\t{ V4L2_COLORSPACE_SRGB, {\n-\t\tColorSpace::Primaries::Rec709,\n-\t\tColorSpace::TransferFunction::Srgb,\n-\t\tColorSpace::YcbcrEncoding::Rec601,\n-\t\tColorSpace::Range::Limited } },\n+\t{ V4L2_COLORSPACE_SRGB, { ColorSpace::Primaries::Rec709, ColorSpace::TransferFunction::Srgb, ColorSpace::YcbcrEncoding::Rec601, ColorSpace::Range::Limited } },\n \t{ V4L2_COLORSPACE_JPEG, ColorSpace::Sycc },\n \t{ V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m },\n \t{ V4L2_COLORSPACE_REC709, ColorSpace::Rec709 },\n\n\nWhat looks fine for me. I think I can post this patch.\n\nBut some other auto-format changes does not look that good.\n\nFor example in src/libcamera/v4l2_subdevice.cpp\nI have bunch of hunks like this \n\n \t{ MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, {\n-\t\t.name = \"RGB444_2X8_PADHI_BE\",\n-\t\t.code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE,\n-\t\t.type = MediaBusFormatInfo::Type::Image,\n-\t\t.bitsPerPixel = 16,\n-\t\t.colourEncoding = PixelFormatInfo::ColourEncodingRGB,\n-\t} },\n+\t\t\t\t\t\t     .name = \"RGB444_2X8_PADHI_BE\",\n+\t\t\t\t\t\t     .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE,\n+\t\t\t\t\t\t     .type = MediaBusFormatInfo::Type::Image,\n+\t\t\t\t\t\t     .bitsPerPixel = 16,\n+\t\t\t\t\t\t     .colourEncoding = PixelFormatInfo::ColourEncodingRGB,\n+\t\t\t\t\t     } },\n \nand one such change\n\n-\tfor (unsigned int index = 0; ; index++) {\n+\tfor (unsigned int index = 0;; index++) {\n\nwhat looks less convenient for me and perhaps is \ncandidate for changing .clang-format rule if possible.\n\nRegards\nStanislaw","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 59DD8BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Feb 2025 08:12:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C0E668742;\n\tWed, 26 Feb 2025 09:12:36 +0100 (CET)","from mgamail.intel.com (mgamail.intel.com [192.198.163.16])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D56C60322\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Feb 2025 09:12:33 +0100 (CET)","from fmviesa008.fm.intel.com ([10.60.135.148])\n\tby fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n\t26 Feb 2025 00:12:32 -0800","from sgruszka-mobl.ger.corp.intel.com (HELO localhost)\n\t([10.246.21.136]) by fmviesa008-auth.fm.intel.com with\n\tESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2025 00:12:30 -0800"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=intel.com header.i=@intel.com\n\theader.b=\"ZkTXWwNd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n\td=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n\tt=1740557554; x=1772093554;\n\th=date:from:to:cc:subject:message-id:references:\n\tmime-version:in-reply-to;\n\tbh=tba5ZO5TTvKcDBBvlH8vVj9/vDQ57Ey/quUbScsKhZM=;\n\tb=ZkTXWwNdIYC5k+yVUeN/3gv+3O66+a2fZ9JgbKhYm1moyJwcLka0pgvw\n\tEX+U5JlH94ib5ZJKqBn2jexJ3vJGofcER4zP2+7gV6p+p0D2+6KJlLeY/\n\tg0hkRRHknReVGYHEK8IP4XRS5tO5+zFY/GBlW85vpKcecPftWDTRq0b6O\n\tmqE0Lh1tQ1Dy3kDZgairNqgWRw0AOjZt+xUGQiluA9tPjmki/LrMBtLD0\n\tdgkmA7NP+nx9OZPfnA8F9/ag8YgD8fSS5th5g69NGQGFForgVSAQFFvku\n\tx21Gw6MOzxkHde3PeBD3oXKNHQpVekhsumzmglJ041TfBv/tT1eflei/P w==;","X-CSE-ConnectionGUID":["CIwdCGVTRnuyzUZxvBjD7A==","zHJlcerkRNmjVqRX7dXMTQ=="],"X-CSE-MsgGUID":["tW2IFznKS2+5MKsZQU8Hsw==","YwQSVgzCTRS1iXb8E2zMMQ=="],"X-IronPort-AV":["E=McAfee;i=\"6700,10204,11356\"; a=\"28983019\"","E=Sophos;i=\"6.13,316,1732608000\"; d=\"scan'208\";a=\"28983019\"","E=Sophos;i=\"6.13,316,1732608000\"; d=\"scan'208\";a=\"116828449\""],"X-ExtLoop1":"1","Date":"Wed, 26 Feb 2025 09:12:28 +0100","From":"Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tMilan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops without\n\texpression","Message-ID":"<Z77M7EwKCX9iOS3D@linux.intel.com>","References":"<20250225152806.22705-1-mzamazal@redhat.com>\n\t<20250225212203.GI18866@pendragon.ideasonboard.com>\n\t<174052524726.673606.12968336202345453139@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<174052524726.673606.12968336202345453139@ping.linuxembedded.co.uk>","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":33496,"web_url":"https://patchwork.libcamera.org/comment/33496/","msgid":"<85ldttqdg6.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-02-26T09:10:01","subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops\n\twithout expression","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Stanislaw,\n\nStanislaw Gruszka <stanislaw.gruszka@linux.intel.com> writes:\n\n> Hi,\n>\n> On Tue, Feb 25, 2025 at 11:14:07PM +0000, Kieran Bingham wrote:\n>> Quoting Laurent Pinchart (2025-02-25 21:22:03)\n>> > Hi Milan,\n>> > \n>> > Thank you for the patch.\n>> > \n>> > On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote:\n>> > > The clang formatter removes spaces in places of empty expressions in for\n>> > > loops.  For example, it changes\n>> > > \n>> > >   for (init; condition; )\n>> > > \n>> > > to\n>> > > \n>> > >   for (init; condition;)\n>> > > \n>> > > libcamera currently uses both the styles and we should use only one of\n>> > > them for consistency.  Since there is apparently no option to override\n>> > > the formatter behavior (see\n>> > > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove\n>> > > the extra spaces to make the formatter happy.\n>> > > \n>> > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>> > \n>> > It's not my favourite style, but I'm OK with it given the inconvenience\n>> > of making it a clang-format exception.\n>> \n>> I remember we discussed this quite some time ago, but I'm fine with\n>> making the formatter happy - that makes all our lives easier.\n>\n> BTW I had formatter issue when editing src/libcamera/v4l2_device.cpp \n> It get me changes like this:\n>\n> @@ -482,11 +482,12 @@ int V4L2Device::setFrameStartEnabled(bool enable)\n>  \tif (frameStartEnabled_ == enable)\n>  \t\treturn 0;\n>  \n> -\tstruct v4l2_event_subscription event{};\n> +\tstruct v4l2_event_subscription event {\n> +\t};\n\nMy clang formatter (19.1.7) is fine with the original version.\n\n>  \tevent.type = V4L2_EVENT_FRAME_SYNC;\n>  \n>  \tunsigned long request = enable ? VIDIOC_SUBSCRIBE_EVENT\n> -\t\t\t      : VIDIOC_UNSUBSCRIBE_EVENT;\n> +\t\t\t\t       : VIDIOC_UNSUBSCRIBE_EVENT;\n\nThis makes sense IMHO.\n\n>  \tint ret = ioctl(request, &event);\n>  \tif (enable && ret)\n>  \t\treturn ret;\n> @@ -828,7 +829,8 @@ void V4L2Device::updateControls(ControlList *ctrls,\n>   */\n>  void V4L2Device::eventAvailable()\n>  {\n> -\tstruct v4l2_event event{};\n> +\tstruct v4l2_event event {\n> +\t};\n>  \tint ret = ioctl(VIDIOC_DQEVENT, &event);\n>  \tif (ret < 0) {\n>  \t\tLOG(V4L2, Error)\n> @@ -850,11 +852,7 @@ void V4L2Device::eventAvailable()\n>  \n>  static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = {\n>  \t{ V4L2_COLORSPACE_RAW, ColorSpace::Raw },\n> -\t{ V4L2_COLORSPACE_SRGB, {\n> -\t\tColorSpace::Primaries::Rec709,\n> -\t\tColorSpace::TransferFunction::Srgb,\n> -\t\tColorSpace::YcbcrEncoding::Rec601,\n> -\t\tColorSpace::Range::Limited } },\n> +\t{ V4L2_COLORSPACE_SRGB, { ColorSpace::Primaries::Rec709, ColorSpace::TransferFunction::Srgb, ColorSpace::YcbcrEncoding::Rec601, ColorSpace::Range::Limited } },\n\nGenerally, the formatter apparently prefers putting the initial brace on\nthe next line.  In this case, this works to avoid the long line:\n\n\t{ V4L2_COLORSPACE_SRGB,\n\t  { ColorSpace::Primaries::Rec709,\n\t    ColorSpace::TransferFunction::Srgb,\n\t    ColorSpace::YcbcrEncoding::Rec601,\n\t    ColorSpace::Range::Limited } },\n\nBut I'm not sure this is aligned with what the maintainers like.\n\n>  \t{ V4L2_COLORSPACE_JPEG, ColorSpace::Sycc },\n>  \t{ V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m },\n>  \t{ V4L2_COLORSPACE_REC709, ColorSpace::Rec709 },\n>\n>\n> What looks fine for me. I think I can post this patch.\n>\n> But some other auto-format changes does not look that good.\n>\n> For example in src/libcamera/v4l2_subdevice.cpp\n> I have bunch of hunks like this \n>\n>  \t{ MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, {\n> -\t\t.name = \"RGB444_2X8_PADHI_BE\",\n> -\t\t.code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE,\n> -\t\t.type = MediaBusFormatInfo::Type::Image,\n> -\t\t.bitsPerPixel = 16,\n> -\t\t.colourEncoding = PixelFormatInfo::ColourEncodingRGB,\n> -\t} },\n> +\t\t\t\t\t\t     .name = \"RGB444_2X8_PADHI_BE\",\n> +\t\t\t\t\t\t     .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE,\n> +\t\t\t\t\t\t     .type = MediaBusFormatInfo::Type::Image,\n> +\t\t\t\t\t\t     .bitsPerPixel = 16,\n> +\t\t\t\t\t\t     .colourEncoding = PixelFormatInfo::ColourEncodingRGB,\n> +\t\t\t\t\t     } },\n\nAgain, with the brace on the next line, it looks better:\n\n\t{ MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE,\n\t  {\n\t\t  .name = \"RGB444_2X8_PADHI_BE\",\n\t\t  .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE,\n\t\t  .type = MediaBusFormatInfo::Type::Image,\n\t\t  .bitsPerPixel = 16,\n\t\t  .colourEncoding = PixelFormatInfo::ColourEncodingRGB,\n\t  } },\n\n> and one such change\n>\n> -\tfor (unsigned int index = 0; ; index++) {\n> +\tfor (unsigned int index = 0;; index++) {\n>\n> what looks less convenient for me and perhaps is \n> candidate for changing .clang-format rule if possible.\n\nI personally mostly stopped caring about formatting after I entered the\ncorporate world -- it's impossible to satisfy everybody and in the end\nresult the code is unreadable for everybody but those that define the\nrules :-).  I use Emacs means to change the code presentation on the\nscreen to avoid the worst offenders and learned to live with that.  An\nideal situation is when a language provides its own canonical tools (see\nRust, Go, ...) because it saves us from all the discussions.\n\nThe only really annoying part is when the formatter constantly changes\nedited sources and I have to discard the changes all the time.  So I\nwelcome any changes (whether in .clang-format or in the source files)\nthat make the formatter and the maintainers more compatible.\n\n> Regards\n> Stanislaw\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 8B0D6BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Feb 2025 09:10:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E85468743;\n\tWed, 26 Feb 2025 10:10:10 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 59D0760322\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Feb 2025 10:10:08 +0100 (CET)","from mail-wr1-f71.google.com (mail-wr1-f71.google.com\n\t[209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-530-8SNbdXcPMdyW38TyXBmN6w-1; Wed, 26 Feb 2025 04:10:05 -0500","by mail-wr1-f71.google.com with SMTP id\n\tffacd0b85a97d-38f2f438fb6so7480071f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Feb 2025 01:10:05 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-390cd8fbb5dsm4742301f8f.84.2025.02.26.01.10.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 26 Feb 2025 01:10:02 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"F56SHxXH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1740561007;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=orhSz4+CcRi5yh9mSaIObDBPVlXGvYveU8fdCZTvn6Q=;\n\tb=F56SHxXHOe1cHr0ggzYIcf8MKPZXKvs075NBDneqcEcC7C2D1pH2zkBdM4jKdZnKN3Rqcq\n\tvIOH5zLpkMGymlkrSzqwSKNlq8ilBIp3KdwU53mnj3SENpBq+il4g/Oe5oO3jz0suTuYMm\n\tm8rnVNAyU/gaqYcArzEEYMVFZsjgKuw=","X-MC-Unique":"8SNbdXcPMdyW38TyXBmN6w-1","X-Mimecast-MFC-AGG-ID":"8SNbdXcPMdyW38TyXBmN6w_1740561004","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1740561004; x=1741165804;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=orhSz4+CcRi5yh9mSaIObDBPVlXGvYveU8fdCZTvn6Q=;\n\tb=SeevPUNa6xEZVtMuRIW0f9jLxLT0pTGpqqygwymbgM03iwfP3SGRinEBO9BKqID1ja\n\t/A1xCpoGgMLNWMqwJfX8s9Jh6IxdOpvYYMZhfj/zO38bj5NZUZFKM8qBEPUzrsyVMc/Y\n\tg21jPTEbtfsAbdVJDe6U0hxVNdp1GxfH4jhK4t+yhTeCJ6UmKkLxFMjpZc+yuYaf3rtE\n\t3MPVBGF3GJwSWIadmT1uRX+jTtTor5f/TCVJ0lbcV1e2e91O0zQVyRwBiPiaPcWV9N9f\n\tVWmgWP1h7flDM4LlaDRuVzEp6M6DFwrH9Q0x0sIqqSF0PPaXsm/iWW3SUmMXBJH5KT+r\n\tMtTg==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCUs5wems11x8hfGOBNvij1vDPdTa8Il9ZuHkA7MyNNpsF4k7y86wMDicZyE3v+kFwhXz9xMBQ8297HojDKcxR4=@lists.libcamera.org","X-Gm-Message-State":"AOJu0YxE1bHI8zAczUN5t7qzh7S2R/78xvPBM5qTOSSiBg9aSjw4JIgs\n\t7W1oMNzGAHoENsY22jE/4RE8E9zaTCH0ekVIJgfg4nHhrMGbY3awAbjXCeNalDda3ujsJHlrFvd\n\tEn24p191l00yImez7HKCmrJAx7hVGf6L6abE+piTpGQ9HHgqn936F2HuviQxeJUbbaldFW8Gsmu\n\ttZUVQoXq+ViFqvKb2MKOrqj0NI67fkKEDaWGQAr+rKnS7ygnOkNNH8aUo=","X-Gm-Gg":"ASbGnctGdkgwJiYhgLiqtHSmlYG1PhDH+DwDrIGfo0ERw1Xai/ma0eEKvfMqF5RvSit\n\t7BHRqew/LD+bivDfen21hFp3Ksv0bUx2gRGkbaezEuPFHvVo31ATtehExyFlOwa2+vSBBRS9FFW\n\tEzYGz3aLdNc5muEdrmc3+ZHk705KZEPDGs82K2nQFw6ie1Bdlps+5zAyHD71EJmsgDJpSfZUFyW\n\ttyt69lsOTVpNqNhcYcdwq7IuueBa5GSNwtR61jrRRkCv9DXMCSE1SayfKnUQhh7RFA4LNQiSkO3\n\tli3a/XTPcsiEpHG4hOOkKBQZ7NakR9ZZotrmg8f60+mY3Lug1WF20uCpkIAHr1MTUsLb","X-Received":["by 2002:a5d:6486:0:b0:38f:31fe:6d12 with SMTP id\n\tffacd0b85a97d-390cc6047c0mr6363288f8f.19.1740561003859; \n\tWed, 26 Feb 2025 01:10:03 -0800 (PST)","by 2002:a5d:6486:0:b0:38f:31fe:6d12 with SMTP id\n\tffacd0b85a97d-390cc6047c0mr6363242f8f.19.1740561003393; \n\tWed, 26 Feb 2025 01:10:03 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IG0kpL/mN4Tgc4DMeO+LCDgTCDDH3JYNTVowV+NoKy4lSjnosxlOVlF3Gv/wgAvLRUTjnQlMA==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,  Laurent Pinchart\n\t<laurent.pinchart@ideasonboard.com>, libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops\n\twithout expression","In-Reply-To":"<Z77M7EwKCX9iOS3D@linux.intel.com> (Stanislaw Gruszka's message\n\tof \"Wed, 26 Feb 2025 09:12:28 +0100\")","References":"<20250225152806.22705-1-mzamazal@redhat.com>\n\t<20250225212203.GI18866@pendragon.ideasonboard.com>\n\t<174052524726.673606.12968336202345453139@ping.linuxembedded.co.uk>\n\t<Z77M7EwKCX9iOS3D@linux.intel.com>","Date":"Wed, 26 Feb 2025 10:10:01 +0100","Message-ID":"<85ldttqdg6.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"IvQWhpMvcOsGSOOrgV04-Uig0tVWMMugkiJeZRbL18s_1740561004","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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":33497,"web_url":"https://patchwork.libcamera.org/comment/33497/","msgid":"<Z770Kwkz8OhlVTCW@linux.intel.com>","date":"2025-02-26T10:59:55","subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops without\n\texpression","submitter":{"id":211,"url":"https://patchwork.libcamera.org/api/people/211/","name":"Stanislaw Gruszka","email":"stanislaw.gruszka@linux.intel.com"},"content":"Hi Milan,\n\nOn Wed, Feb 26, 2025 at 10:10:01AM +0100, Milan Zamazal wrote:\n> Hi Stanislaw,\n> \n> Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> writes:\n> \n> > Hi,\n> >\n> > On Tue, Feb 25, 2025 at 11:14:07PM +0000, Kieran Bingham wrote:\n> >> Quoting Laurent Pinchart (2025-02-25 21:22:03)\n> >> > Hi Milan,\n> >> > \n> >> > Thank you for the patch.\n> >> > \n> >> > On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote:\n> >> > > The clang formatter removes spaces in places of empty expressions in for\n> >> > > loops.  For example, it changes\n> >> > > \n> >> > >   for (init; condition; )\n> >> > > \n> >> > > to\n> >> > > \n> >> > >   for (init; condition;)\n> >> > > \n> >> > > libcamera currently uses both the styles and we should use only one of\n> >> > > them for consistency.  Since there is apparently no option to override\n> >> > > the formatter behavior (see\n> >> > > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove\n> >> > > the extra spaces to make the formatter happy.\n> >> > > \n> >> > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> >> > \n> >> > It's not my favourite style, but I'm OK with it given the inconvenience\n> >> > of making it a clang-format exception.\n> >> \n> >> I remember we discussed this quite some time ago, but I'm fine with\n> >> making the formatter happy - that makes all our lives easier.\n> >\n> > BTW I had formatter issue when editing src/libcamera/v4l2_device.cpp \n> > It get me changes like this:\n> >\n> > @@ -482,11 +482,12 @@ int V4L2Device::setFrameStartEnabled(bool enable)\n> >  \tif (frameStartEnabled_ == enable)\n> >  \t\treturn 0;\n> >  \n> > -\tstruct v4l2_event_subscription event{};\n> > +\tstruct v4l2_event_subscription event {\n> > +\t};\n> \n> My clang formatter (19.1.7) is fine with the original version.\n\nInteresting , I have \n\nUbuntu clang-format version 19.1.1 (1ubuntu1~24.04.2)\n\nand it does the change.\n\n> >  void V4L2Device::eventAvailable()\n> >  {\n> > -\tstruct v4l2_event event{};\n> > +\tstruct v4l2_event event {\n> > +\t};\n> >  \tint ret = ioctl(VIDIOC_DQEVENT, &event);\n> >  \tif (ret < 0) {\n> >  \t\tLOG(V4L2, Error)\n> > @@ -850,11 +852,7 @@ void V4L2Device::eventAvailable()\n> >  \n> >  static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = {\n> >  \t{ V4L2_COLORSPACE_RAW, ColorSpace::Raw },\n> > -\t{ V4L2_COLORSPACE_SRGB, {\n> > -\t\tColorSpace::Primaries::Rec709,\n> > -\t\tColorSpace::TransferFunction::Srgb,\n> > -\t\tColorSpace::YcbcrEncoding::Rec601,\n> > -\t\tColorSpace::Range::Limited } },\n> > +\t{ V4L2_COLORSPACE_SRGB, { ColorSpace::Primaries::Rec709, ColorSpace::TransferFunction::Srgb, ColorSpace::YcbcrEncoding::Rec601, ColorSpace::Range::Limited } },\n> \n> Generally, the formatter apparently prefers putting the initial brace on\n> the next line.  In this case, this works to avoid the long line:\n\nGood to know.\n\n> \n> \t{ V4L2_COLORSPACE_SRGB,\n> \t  { ColorSpace::Primaries::Rec709,\n> \t    ColorSpace::TransferFunction::Srgb,\n> \t    ColorSpace::YcbcrEncoding::Rec601,\n> \t    ColorSpace::Range::Limited } },\n> \n> But I'm not sure this is aligned with what the maintainers like.\n\nFor me personally both formats are ok.\n\n> > and one such change\n> >\n> > -\tfor (unsigned int index = 0; ; index++) {\n> > +\tfor (unsigned int index = 0;; index++) {\n> >\n> > what looks less convenient for me and perhaps is \n> > candidate for changing .clang-format rule if possible.\n> \n> I personally mostly stopped caring about formatting after I entered the\n> corporate world -- it's impossible to satisfy everybody and in the end\n> result the code is unreadable for everybody but those that define the\n> rules :-).  I use Emacs means to change the code presentation on the\n> screen to avoid the worst offenders and learned to live with that.  An\n> ideal situation is when a language provides its own canonical tools (see\n> Rust, Go, ...) because it saves us from all the discussions.\n> \n> The only really annoying part is when the formatter constantly changes\n> edited sources and I have to discard the changes all the time.  So I\n> welcome any changes (whether in .clang-format or in the source files)\n> that make the formatter and the maintainers more compatible.\n\nThis annoys me a bit too.\n\nI need to configure my editor - neovim to do autoformatting only to\nlines that I changed and do not modify whole file. So far I was too \nlazy to do so.\n\nFortunately many files in libcamera are already formatted thanks to\npaches like this one :-)\n\nThanks\nStanislaw","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 4DBBFC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Feb 2025 11:00:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 39BB660322;\n\tWed, 26 Feb 2025 12:00:04 +0100 (CET)","from mgamail.intel.com (mgamail.intel.com [198.175.65.11])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3131B60322\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Feb 2025 12:00:01 +0100 (CET)","from orviesa005.jf.intel.com ([10.64.159.145])\n\tby orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n\t26 Feb 2025 03:00:00 -0800","from sgruszka-mobl.ger.corp.intel.com (HELO localhost)\n\t([10.246.21.136]) by orviesa005-auth.jf.intel.com with\n\tESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2025 02:59:58 -0800"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=intel.com header.i=@intel.com\n\theader.b=\"DF0dqrK0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n\td=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n\tt=1740567602; x=1772103602;\n\th=date:from:to:cc:subject:message-id:references:\n\tmime-version:in-reply-to;\n\tbh=PSzDfHykpKMfXFLeeBBHS8FFr6XMl/7xbKk4Eq29SRs=;\n\tb=DF0dqrK0D9bfiNXBDf4J05VwOfWC7bLdLj3pqbfrP2ZvQQWhcfTFE9cm\n\tJ/G1ndvxFGwmwsG7Midu0WkPrRNCz9TN4LHgrHinRT4afp96ctYPNvc9T\n\tNImm8AYSrg4fR7GV3AdWr/8WgMrQskjtN1YFUNVZw+PENNWqIASdlWb37\n\tKjT1ecKPOY7P9dmEWE/sXx+ci2or9udx1YgiaoWttY4Z6ofvMHejX2cfU\n\towfJof0+pjdm7H/OhAfWqss4X4Sp/zjAHuYNwVR7j5OQVx9NRyVyZz6MS\n\tGgztKCM3FdWPBpXea06aGj8PPJCO6c2vJFjopQO83R+N2uqouvoH7QQzW Q==;","X-CSE-ConnectionGUID":["tgYFF3XJSiqOL9kSn5MthA==","fWOAlEnTRKGyp83qv/UW+g=="],"X-CSE-MsgGUID":["WvQW7mcCQCePgIU+6hIm/Q==","OjLux3qDSlWURfhGah4sFA=="],"X-IronPort-AV":["E=McAfee;i=\"6700,10204,11356\"; a=\"51616409\"","E=Sophos;i=\"6.13,316,1732608000\"; d=\"scan'208\";a=\"51616409\"","E=Sophos;i=\"6.12,224,1728975600\"; d=\"scan'208\";a=\"121918318\""],"X-ExtLoop1":"1","Date":"Wed, 26 Feb 2025 11:59:55 +0100","From":"Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] libcamera: formatting: Avoid spaces in for loops without\n\texpression","Message-ID":"<Z770Kwkz8OhlVTCW@linux.intel.com>","References":"<20250225152806.22705-1-mzamazal@redhat.com>\n\t<20250225212203.GI18866@pendragon.ideasonboard.com>\n\t<174052524726.673606.12968336202345453139@ping.linuxembedded.co.uk>\n\t<Z77M7EwKCX9iOS3D@linux.intel.com>\n\t<85ldttqdg6.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<85ldttqdg6.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","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>"}}]