[PATCH] libcamera: formatting: Avoid spaces in for loops without expression
Kieran Bingham
kieran.bingham at ideasonboard.com
Wed Feb 26 00:14:07 CET 2025
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 at 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 at ideasonboard.com>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at 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
More information about the libcamera-devel
mailing list