Message ID | 20250225152806.22705-1-mzamazal@redhat.com |
---|---|
State | Accepted |
Commit | 33ce463a46c44f874fdbc3e484bee730e7b251a3 |
Headers | show |
Series |
|
Related | show |
Hi Milan, Thank you for the patch. On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote: > The clang formatter removes spaces in places of empty expressions in for > loops. For example, it changes > > for (init; condition; ) > > to > > for (init; condition;) > > libcamera currently uses both the styles and we should use only one of > them for consistency. Since there is apparently no option to override > the formatter behavior (see > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove > the extra spaces to make the formatter happy. > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> It's not my favourite style, but I'm OK with it given the inconvenience of making it a clang-format exception. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/apps/common/options.cpp | 2 +- > src/apps/qcam/format_converter.cpp | 2 +- > src/libcamera/base/object.cpp | 2 +- > src/libcamera/base/signal.cpp | 2 +- > src/libcamera/base/thread.cpp | 2 +- > src/libcamera/process.cpp | 2 +- > 6 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp > index ece268d0..cae193cc 100644 > --- a/src/apps/common/options.cpp > +++ b/src/apps/common/options.cpp > @@ -1040,7 +1040,7 @@ void OptionsParser::usageOptions(const std::list<Option> &options, > > std::cerr << std::setw(indent) << argument; > > - for (const char *help = option.help, *end = help; end; ) { > + for (const char *help = option.help, *end = help; end;) { > end = strchr(help, '\n'); > if (end) { > std::cerr << std::string(help, end - help + 1); > diff --git a/src/apps/qcam/format_converter.cpp b/src/apps/qcam/format_converter.cpp > index 32123493..b025a3c7 100644 > --- a/src/apps/qcam/format_converter.cpp > +++ b/src/apps/qcam/format_converter.cpp > @@ -249,7 +249,7 @@ void FormatConverter::convertYUVPacked(const Image *srcImage, unsigned char *dst > dst_stride = width_ * 4; > > for (src_y = 0, dst_y = 0; dst_y < height_; src_y++, dst_y++) { > - for (src_x = 0, dst_x = 0; dst_x < width_; ) { > + for (src_x = 0, dst_x = 0; dst_x < width_;) { > cb = src[src_y * src_stride + src_x * 4 + cb_pos_]; > cr = src[src_y * src_stride + src_x * 4 + cr_pos]; > > diff --git a/src/libcamera/base/object.cpp b/src/libcamera/base/object.cpp > index 745d2565..37d133cc 100644 > --- a/src/libcamera/base/object.cpp > +++ b/src/libcamera/base/object.cpp > @@ -350,7 +350,7 @@ void Object::connect(SignalBase *signal) > > void Object::disconnect(SignalBase *signal) > { > - for (auto iter = signals_.begin(); iter != signals_.end(); ) { > + for (auto iter = signals_.begin(); iter != signals_.end();) { > if (*iter == signal) > iter = signals_.erase(iter); > else > diff --git a/src/libcamera/base/signal.cpp b/src/libcamera/base/signal.cpp > index b782e050..7876a21d 100644 > --- a/src/libcamera/base/signal.cpp > +++ b/src/libcamera/base/signal.cpp > @@ -49,7 +49,7 @@ void SignalBase::disconnect(std::function<bool(SlotList::iterator &)> match) > { > MutexLocker locker(signalsLock); > > - for (auto iter = slots_.begin(); iter != slots_.end(); ) { > + for (auto iter = slots_.begin(); iter != slots_.end();) { > if (match(iter)) { > Object *object = (*iter)->object(); > if (object) > diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp > index 319bfda9..646ad3cb 100644 > --- a/src/libcamera/base/thread.cpp > +++ b/src/libcamera/base/thread.cpp > @@ -657,7 +657,7 @@ void Thread::dispatchMessages(Message::Type type) > * the outer calls. > */ > if (!--data_->messages_.recursion_) { > - for (auto iter = messages.begin(); iter != messages.end(); ) { > + for (auto iter = messages.begin(); iter != messages.end();) { > if (!*iter) > iter = messages.erase(iter); > else > diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp > index bc9833f4..68fad327 100644 > --- a/src/libcamera/process.cpp > +++ b/src/libcamera/process.cpp > @@ -75,7 +75,7 @@ void ProcessManager::sighandler() > return; > } > > - for (auto it = processes_.begin(); it != processes_.end(); ) { > + for (auto it = processes_.begin(); it != processes_.end();) { > Process *process = *it; > > int wstatus;
Quoting Laurent Pinchart (2025-02-25 21:22:03) > Hi Milan, > > Thank you for the patch. > > On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote: > > The clang formatter removes spaces in places of empty expressions in for > > loops. For example, it changes > > > > for (init; condition; ) > > > > to > > > > for (init; condition;) > > > > libcamera currently uses both the styles and we should use only one of > > them for consistency. Since there is apparently no option to override > > the formatter behavior (see > > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove > > the extra spaces to make the formatter happy. > > > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> > > It's not my favourite style, but I'm OK with it given the inconvenience > of making it a clang-format exception. I remember we discussed this quite some time ago, but I'm fine with making the formatter happy - that makes all our lives easier. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > > --- > > src/apps/common/options.cpp | 2 +- > > src/apps/qcam/format_converter.cpp | 2 +- > > src/libcamera/base/object.cpp | 2 +- > > src/libcamera/base/signal.cpp | 2 +- > > src/libcamera/base/thread.cpp | 2 +- > > src/libcamera/process.cpp | 2 +- > > 6 files changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp > > index ece268d0..cae193cc 100644 > > --- a/src/apps/common/options.cpp > > +++ b/src/apps/common/options.cpp > > @@ -1040,7 +1040,7 @@ void OptionsParser::usageOptions(const std::list<Option> &options, > > > > std::cerr << std::setw(indent) << argument; > > > > - for (const char *help = option.help, *end = help; end; ) { > > + for (const char *help = option.help, *end = help; end;) { > > end = strchr(help, '\n'); > > if (end) { > > std::cerr << std::string(help, end - help + 1); > > diff --git a/src/apps/qcam/format_converter.cpp b/src/apps/qcam/format_converter.cpp > > index 32123493..b025a3c7 100644 > > --- a/src/apps/qcam/format_converter.cpp > > +++ b/src/apps/qcam/format_converter.cpp > > @@ -249,7 +249,7 @@ void FormatConverter::convertYUVPacked(const Image *srcImage, unsigned char *dst > > dst_stride = width_ * 4; > > > > for (src_y = 0, dst_y = 0; dst_y < height_; src_y++, dst_y++) { > > - for (src_x = 0, dst_x = 0; dst_x < width_; ) { > > + for (src_x = 0, dst_x = 0; dst_x < width_;) { > > cb = src[src_y * src_stride + src_x * 4 + cb_pos_]; > > cr = src[src_y * src_stride + src_x * 4 + cr_pos]; > > > > diff --git a/src/libcamera/base/object.cpp b/src/libcamera/base/object.cpp > > index 745d2565..37d133cc 100644 > > --- a/src/libcamera/base/object.cpp > > +++ b/src/libcamera/base/object.cpp > > @@ -350,7 +350,7 @@ void Object::connect(SignalBase *signal) > > > > void Object::disconnect(SignalBase *signal) > > { > > - for (auto iter = signals_.begin(); iter != signals_.end(); ) { > > + for (auto iter = signals_.begin(); iter != signals_.end();) { > > if (*iter == signal) > > iter = signals_.erase(iter); > > else > > diff --git a/src/libcamera/base/signal.cpp b/src/libcamera/base/signal.cpp > > index b782e050..7876a21d 100644 > > --- a/src/libcamera/base/signal.cpp > > +++ b/src/libcamera/base/signal.cpp > > @@ -49,7 +49,7 @@ void SignalBase::disconnect(std::function<bool(SlotList::iterator &)> match) > > { > > MutexLocker locker(signalsLock); > > > > - for (auto iter = slots_.begin(); iter != slots_.end(); ) { > > + for (auto iter = slots_.begin(); iter != slots_.end();) { > > if (match(iter)) { > > Object *object = (*iter)->object(); > > if (object) > > diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp > > index 319bfda9..646ad3cb 100644 > > --- a/src/libcamera/base/thread.cpp > > +++ b/src/libcamera/base/thread.cpp > > @@ -657,7 +657,7 @@ void Thread::dispatchMessages(Message::Type type) > > * the outer calls. > > */ > > if (!--data_->messages_.recursion_) { > > - for (auto iter = messages.begin(); iter != messages.end(); ) { > > + for (auto iter = messages.begin(); iter != messages.end();) { > > if (!*iter) > > iter = messages.erase(iter); > > else > > diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp > > index bc9833f4..68fad327 100644 > > --- a/src/libcamera/process.cpp > > +++ b/src/libcamera/process.cpp > > @@ -75,7 +75,7 @@ void ProcessManager::sighandler() > > return; > > } > > > > - for (auto it = processes_.begin(); it != processes_.end(); ) { > > + for (auto it = processes_.begin(); it != processes_.end();) { > > Process *process = *it; > > > > int wstatus; > > -- > Regards, > > Laurent Pinchart
Hi, On Tue, Feb 25, 2025 at 11:14:07PM +0000, Kieran Bingham wrote: > Quoting Laurent Pinchart (2025-02-25 21:22:03) > > Hi Milan, > > > > Thank you for the patch. > > > > On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote: > > > The clang formatter removes spaces in places of empty expressions in for > > > loops. For example, it changes > > > > > > for (init; condition; ) > > > > > > to > > > > > > for (init; condition;) > > > > > > libcamera currently uses both the styles and we should use only one of > > > them for consistency. Since there is apparently no option to override > > > the formatter behavior (see > > > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove > > > the extra spaces to make the formatter happy. > > > > > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> > > > > It's not my favourite style, but I'm OK with it given the inconvenience > > of making it a clang-format exception. > > I remember we discussed this quite some time ago, but I'm fine with > making the formatter happy - that makes all our lives easier. BTW I had formatter issue when editing src/libcamera/v4l2_device.cpp It get me changes like this: @@ -482,11 +482,12 @@ int V4L2Device::setFrameStartEnabled(bool enable) if (frameStartEnabled_ == enable) return 0; - struct v4l2_event_subscription event{}; + struct v4l2_event_subscription event { + }; event.type = V4L2_EVENT_FRAME_SYNC; unsigned long request = enable ? VIDIOC_SUBSCRIBE_EVENT - : VIDIOC_UNSUBSCRIBE_EVENT; + : VIDIOC_UNSUBSCRIBE_EVENT; int ret = ioctl(request, &event); if (enable && ret) return ret; @@ -828,7 +829,8 @@ void V4L2Device::updateControls(ControlList *ctrls, */ void V4L2Device::eventAvailable() { - struct v4l2_event event{}; + struct v4l2_event event { + }; int ret = ioctl(VIDIOC_DQEVENT, &event); if (ret < 0) { LOG(V4L2, Error) @@ -850,11 +852,7 @@ void V4L2Device::eventAvailable() static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = { { V4L2_COLORSPACE_RAW, ColorSpace::Raw }, - { V4L2_COLORSPACE_SRGB, { - ColorSpace::Primaries::Rec709, - ColorSpace::TransferFunction::Srgb, - ColorSpace::YcbcrEncoding::Rec601, - ColorSpace::Range::Limited } }, + { V4L2_COLORSPACE_SRGB, { ColorSpace::Primaries::Rec709, ColorSpace::TransferFunction::Srgb, ColorSpace::YcbcrEncoding::Rec601, ColorSpace::Range::Limited } }, { V4L2_COLORSPACE_JPEG, ColorSpace::Sycc }, { V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m }, { V4L2_COLORSPACE_REC709, ColorSpace::Rec709 }, What looks fine for me. I think I can post this patch. But some other auto-format changes does not look that good. For example in src/libcamera/v4l2_subdevice.cpp I have bunch of hunks like this { MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, { - .name = "RGB444_2X8_PADHI_BE", - .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, - .type = MediaBusFormatInfo::Type::Image, - .bitsPerPixel = 16, - .colourEncoding = PixelFormatInfo::ColourEncodingRGB, - } }, + .name = "RGB444_2X8_PADHI_BE", + .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, + .type = MediaBusFormatInfo::Type::Image, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + } }, and one such change - for (unsigned int index = 0; ; index++) { + for (unsigned int index = 0;; index++) { what looks less convenient for me and perhaps is candidate for changing .clang-format rule if possible. Regards Stanislaw
Hi Stanislaw, Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> writes: > Hi, > > On Tue, Feb 25, 2025 at 11:14:07PM +0000, Kieran Bingham wrote: >> Quoting Laurent Pinchart (2025-02-25 21:22:03) >> > Hi Milan, >> > >> > Thank you for the patch. >> > >> > On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote: >> > > The clang formatter removes spaces in places of empty expressions in for >> > > loops. For example, it changes >> > > >> > > for (init; condition; ) >> > > >> > > to >> > > >> > > for (init; condition;) >> > > >> > > libcamera currently uses both the styles and we should use only one of >> > > them for consistency. Since there is apparently no option to override >> > > the formatter behavior (see >> > > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove >> > > the extra spaces to make the formatter happy. >> > > >> > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> >> > >> > It's not my favourite style, but I'm OK with it given the inconvenience >> > of making it a clang-format exception. >> >> I remember we discussed this quite some time ago, but I'm fine with >> making the formatter happy - that makes all our lives easier. > > BTW I had formatter issue when editing src/libcamera/v4l2_device.cpp > It get me changes like this: > > @@ -482,11 +482,12 @@ int V4L2Device::setFrameStartEnabled(bool enable) > if (frameStartEnabled_ == enable) > return 0; > > - struct v4l2_event_subscription event{}; > + struct v4l2_event_subscription event { > + }; My clang formatter (19.1.7) is fine with the original version. > event.type = V4L2_EVENT_FRAME_SYNC; > > unsigned long request = enable ? VIDIOC_SUBSCRIBE_EVENT > - : VIDIOC_UNSUBSCRIBE_EVENT; > + : VIDIOC_UNSUBSCRIBE_EVENT; This makes sense IMHO. > int ret = ioctl(request, &event); > if (enable && ret) > return ret; > @@ -828,7 +829,8 @@ void V4L2Device::updateControls(ControlList *ctrls, > */ > void V4L2Device::eventAvailable() > { > - struct v4l2_event event{}; > + struct v4l2_event event { > + }; > int ret = ioctl(VIDIOC_DQEVENT, &event); > if (ret < 0) { > LOG(V4L2, Error) > @@ -850,11 +852,7 @@ void V4L2Device::eventAvailable() > > static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = { > { V4L2_COLORSPACE_RAW, ColorSpace::Raw }, > - { V4L2_COLORSPACE_SRGB, { > - ColorSpace::Primaries::Rec709, > - ColorSpace::TransferFunction::Srgb, > - ColorSpace::YcbcrEncoding::Rec601, > - ColorSpace::Range::Limited } }, > + { V4L2_COLORSPACE_SRGB, { ColorSpace::Primaries::Rec709, ColorSpace::TransferFunction::Srgb, ColorSpace::YcbcrEncoding::Rec601, ColorSpace::Range::Limited } }, Generally, the formatter apparently prefers putting the initial brace on the next line. In this case, this works to avoid the long line: { V4L2_COLORSPACE_SRGB, { ColorSpace::Primaries::Rec709, ColorSpace::TransferFunction::Srgb, ColorSpace::YcbcrEncoding::Rec601, ColorSpace::Range::Limited } }, But I'm not sure this is aligned with what the maintainers like. > { V4L2_COLORSPACE_JPEG, ColorSpace::Sycc }, > { V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m }, > { V4L2_COLORSPACE_REC709, ColorSpace::Rec709 }, > > > What looks fine for me. I think I can post this patch. > > But some other auto-format changes does not look that good. > > For example in src/libcamera/v4l2_subdevice.cpp > I have bunch of hunks like this > > { MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, { > - .name = "RGB444_2X8_PADHI_BE", > - .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, > - .type = MediaBusFormatInfo::Type::Image, > - .bitsPerPixel = 16, > - .colourEncoding = PixelFormatInfo::ColourEncodingRGB, > - } }, > + .name = "RGB444_2X8_PADHI_BE", > + .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, > + .type = MediaBusFormatInfo::Type::Image, > + .bitsPerPixel = 16, > + .colourEncoding = PixelFormatInfo::ColourEncodingRGB, > + } }, Again, with the brace on the next line, it looks better: { MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, { .name = "RGB444_2X8_PADHI_BE", .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, } }, > and one such change > > - for (unsigned int index = 0; ; index++) { > + for (unsigned int index = 0;; index++) { > > what looks less convenient for me and perhaps is > candidate for changing .clang-format rule if possible. I personally mostly stopped caring about formatting after I entered the corporate world -- it's impossible to satisfy everybody and in the end result the code is unreadable for everybody but those that define the rules :-). I use Emacs means to change the code presentation on the screen to avoid the worst offenders and learned to live with that. An ideal situation is when a language provides its own canonical tools (see Rust, Go, ...) because it saves us from all the discussions. The only really annoying part is when the formatter constantly changes edited sources and I have to discard the changes all the time. So I welcome any changes (whether in .clang-format or in the source files) that make the formatter and the maintainers more compatible. > Regards > Stanislaw >
Hi Milan, On Wed, Feb 26, 2025 at 10:10:01AM +0100, Milan Zamazal wrote: > Hi Stanislaw, > > Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> writes: > > > Hi, > > > > On Tue, Feb 25, 2025 at 11:14:07PM +0000, Kieran Bingham wrote: > >> Quoting Laurent Pinchart (2025-02-25 21:22:03) > >> > Hi Milan, > >> > > >> > Thank you for the patch. > >> > > >> > On Tue, Feb 25, 2025 at 04:28:06PM +0100, Milan Zamazal wrote: > >> > > The clang formatter removes spaces in places of empty expressions in for > >> > > loops. For example, it changes > >> > > > >> > > for (init; condition; ) > >> > > > >> > > to > >> > > > >> > > for (init; condition;) > >> > > > >> > > libcamera currently uses both the styles and we should use only one of > >> > > them for consistency. Since there is apparently no option to override > >> > > the formatter behavior (see > >> > > https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove > >> > > the extra spaces to make the formatter happy. > >> > > > >> > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> > >> > > >> > It's not my favourite style, but I'm OK with it given the inconvenience > >> > of making it a clang-format exception. > >> > >> I remember we discussed this quite some time ago, but I'm fine with > >> making the formatter happy - that makes all our lives easier. > > > > BTW I had formatter issue when editing src/libcamera/v4l2_device.cpp > > It get me changes like this: > > > > @@ -482,11 +482,12 @@ int V4L2Device::setFrameStartEnabled(bool enable) > > if (frameStartEnabled_ == enable) > > return 0; > > > > - struct v4l2_event_subscription event{}; > > + struct v4l2_event_subscription event { > > + }; > > My clang formatter (19.1.7) is fine with the original version. Interesting , I have Ubuntu clang-format version 19.1.1 (1ubuntu1~24.04.2) and it does the change. > > void V4L2Device::eventAvailable() > > { > > - struct v4l2_event event{}; > > + struct v4l2_event event { > > + }; > > int ret = ioctl(VIDIOC_DQEVENT, &event); > > if (ret < 0) { > > LOG(V4L2, Error) > > @@ -850,11 +852,7 @@ void V4L2Device::eventAvailable() > > > > static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = { > > { V4L2_COLORSPACE_RAW, ColorSpace::Raw }, > > - { V4L2_COLORSPACE_SRGB, { > > - ColorSpace::Primaries::Rec709, > > - ColorSpace::TransferFunction::Srgb, > > - ColorSpace::YcbcrEncoding::Rec601, > > - ColorSpace::Range::Limited } }, > > + { V4L2_COLORSPACE_SRGB, { ColorSpace::Primaries::Rec709, ColorSpace::TransferFunction::Srgb, ColorSpace::YcbcrEncoding::Rec601, ColorSpace::Range::Limited } }, > > Generally, the formatter apparently prefers putting the initial brace on > the next line. In this case, this works to avoid the long line: Good to know. > > { V4L2_COLORSPACE_SRGB, > { ColorSpace::Primaries::Rec709, > ColorSpace::TransferFunction::Srgb, > ColorSpace::YcbcrEncoding::Rec601, > ColorSpace::Range::Limited } }, > > But I'm not sure this is aligned with what the maintainers like. For me personally both formats are ok. > > and one such change > > > > - for (unsigned int index = 0; ; index++) { > > + for (unsigned int index = 0;; index++) { > > > > what looks less convenient for me and perhaps is > > candidate for changing .clang-format rule if possible. > > I personally mostly stopped caring about formatting after I entered the > corporate world -- it's impossible to satisfy everybody and in the end > result the code is unreadable for everybody but those that define the > rules :-). I use Emacs means to change the code presentation on the > screen to avoid the worst offenders and learned to live with that. An > ideal situation is when a language provides its own canonical tools (see > Rust, Go, ...) because it saves us from all the discussions. > > The only really annoying part is when the formatter constantly changes > edited sources and I have to discard the changes all the time. So I > welcome any changes (whether in .clang-format or in the source files) > that make the formatter and the maintainers more compatible. This annoys me a bit too. I need to configure my editor - neovim to do autoformatting only to lines that I changed and do not modify whole file. So far I was too lazy to do so. Fortunately many files in libcamera are already formatted thanks to paches like this one :-) Thanks Stanislaw
diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp index ece268d0..cae193cc 100644 --- a/src/apps/common/options.cpp +++ b/src/apps/common/options.cpp @@ -1040,7 +1040,7 @@ void OptionsParser::usageOptions(const std::list<Option> &options, std::cerr << std::setw(indent) << argument; - for (const char *help = option.help, *end = help; end; ) { + for (const char *help = option.help, *end = help; end;) { end = strchr(help, '\n'); if (end) { std::cerr << std::string(help, end - help + 1); diff --git a/src/apps/qcam/format_converter.cpp b/src/apps/qcam/format_converter.cpp index 32123493..b025a3c7 100644 --- a/src/apps/qcam/format_converter.cpp +++ b/src/apps/qcam/format_converter.cpp @@ -249,7 +249,7 @@ void FormatConverter::convertYUVPacked(const Image *srcImage, unsigned char *dst dst_stride = width_ * 4; for (src_y = 0, dst_y = 0; dst_y < height_; src_y++, dst_y++) { - for (src_x = 0, dst_x = 0; dst_x < width_; ) { + for (src_x = 0, dst_x = 0; dst_x < width_;) { cb = src[src_y * src_stride + src_x * 4 + cb_pos_]; cr = src[src_y * src_stride + src_x * 4 + cr_pos]; diff --git a/src/libcamera/base/object.cpp b/src/libcamera/base/object.cpp index 745d2565..37d133cc 100644 --- a/src/libcamera/base/object.cpp +++ b/src/libcamera/base/object.cpp @@ -350,7 +350,7 @@ void Object::connect(SignalBase *signal) void Object::disconnect(SignalBase *signal) { - for (auto iter = signals_.begin(); iter != signals_.end(); ) { + for (auto iter = signals_.begin(); iter != signals_.end();) { if (*iter == signal) iter = signals_.erase(iter); else diff --git a/src/libcamera/base/signal.cpp b/src/libcamera/base/signal.cpp index b782e050..7876a21d 100644 --- a/src/libcamera/base/signal.cpp +++ b/src/libcamera/base/signal.cpp @@ -49,7 +49,7 @@ void SignalBase::disconnect(std::function<bool(SlotList::iterator &)> match) { MutexLocker locker(signalsLock); - for (auto iter = slots_.begin(); iter != slots_.end(); ) { + for (auto iter = slots_.begin(); iter != slots_.end();) { if (match(iter)) { Object *object = (*iter)->object(); if (object) diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index 319bfda9..646ad3cb 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -657,7 +657,7 @@ void Thread::dispatchMessages(Message::Type type) * the outer calls. */ if (!--data_->messages_.recursion_) { - for (auto iter = messages.begin(); iter != messages.end(); ) { + for (auto iter = messages.begin(); iter != messages.end();) { if (!*iter) iter = messages.erase(iter); else diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index bc9833f4..68fad327 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -75,7 +75,7 @@ void ProcessManager::sighandler() return; } - for (auto it = processes_.begin(); it != processes_.end(); ) { + for (auto it = processes_.begin(); it != processes_.end();) { Process *process = *it; int wstatus;
The clang formatter removes spaces in places of empty expressions in for loops. For example, it changes for (init; condition; ) to for (init; condition;) libcamera currently uses both the styles and we should use only one of them for consistency. Since there is apparently no option to override the formatter behavior (see https://clang.llvm.org/docs/ClangFormatStyleOptions.html), let's remove the extra spaces to make the formatter happy. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> --- src/apps/common/options.cpp | 2 +- src/apps/qcam/format_converter.cpp | 2 +- src/libcamera/base/object.cpp | 2 +- src/libcamera/base/signal.cpp | 2 +- src/libcamera/base/thread.cpp | 2 +- src/libcamera/process.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)