clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version.  The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.

See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.

Change-Id: I6c62f244ae77c511ecbb62b72964154f465fb590
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
 IndentWrappedFunctionNames: true
 InsertNewlineAtEOF: true
 KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
 LineEnding: LF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
@@ -98,13 +98,14 @@
 ObjCSpaceBeforeProtocolList: true
 PackConstructorInitializers: BinPack
 PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
 PointerAlignment: Left
 QualifierAlignment: Left
 ReferenceAlignment: Left
diff --git a/src/sdeventplus/event.cpp b/src/sdeventplus/event.cpp
index 0c9d0d9..92b2afe 100644
--- a/src/sdeventplus/event.cpp
+++ b/src/sdeventplus/event.cpp
@@ -17,8 +17,7 @@
 
 Event::Event(sd_event* event, std::false_type,
              const internal::SdEvent* sdevent) :
-    sdevent(sdevent),
-    event(std::move(event), sdevent, true)
+    sdevent(sdevent), event(std::move(event), sdevent, true)
 {}
 
 Event::Event(const Event& other, sdeventplus::internal::NoOwn) :
diff --git a/src/sdeventplus/event.hpp b/src/sdeventplus/event.hpp
index 8b3e9ce..bbaabe1 100644
--- a/src/sdeventplus/event.hpp
+++ b/src/sdeventplus/event.hpp
@@ -165,8 +165,8 @@
                      bool& owned);
 
     const internal::SdEvent* sdevent;
-    stdplus::Copyable<sd_event*, const internal::SdEvent*, bool>::Handle<drop,
-                                                                         ref>
+    stdplus::Copyable<sd_event*, const internal::SdEvent*,
+                      bool>::Handle<drop, ref>
         event;
 };
 
diff --git a/src/sdeventplus/internal/sdevent.cpp b/src/sdeventplus/internal/sdevent.cpp
index f3bdeb3..3a17408 100644
--- a/src/sdeventplus/internal/sdevent.cpp
+++ b/src/sdeventplus/internal/sdevent.cpp
@@ -27,19 +27,16 @@
     return ::sd_event_unref(event);
 }
 
-int SdEventImpl::sd_event_add_io(sd_event* event, sd_event_source** source,
-                                 int fd, uint32_t events,
-                                 sd_event_io_handler_t callback,
-                                 void* userdata) const
+int SdEventImpl::sd_event_add_io(
+    sd_event* event, sd_event_source** source, int fd, uint32_t events,
+    sd_event_io_handler_t callback, void* userdata) const
 {
     return ::sd_event_add_io(event, source, fd, events, callback, userdata);
 }
 
-int SdEventImpl::sd_event_add_time(sd_event* event, sd_event_source** source,
-                                   clockid_t clock, uint64_t usec,
-                                   uint64_t accuracy,
-                                   sd_event_time_handler_t callback,
-                                   void* userdata) const
+int SdEventImpl::sd_event_add_time(
+    sd_event* event, sd_event_source** source, clockid_t clock, uint64_t usec,
+    uint64_t accuracy, sd_event_time_handler_t callback, void* userdata) const
 {
     return ::sd_event_add_time(event, source, clock, usec, accuracy, callback,
                                userdata);
diff --git a/src/sdeventplus/internal/sdevent.hpp b/src/sdeventplus/internal/sdevent.hpp
index ceab0fe..ee73259 100644
--- a/src/sdeventplus/internal/sdevent.hpp
+++ b/src/sdeventplus/internal/sdevent.hpp
@@ -23,18 +23,16 @@
     virtual int sd_event_add_io(sd_event* event, sd_event_source** source,
                                 int fd, uint32_t events, sd_event_io_handler_t,
                                 void* userdata) const = 0;
-    virtual int sd_event_add_time(sd_event* event, sd_event_source** source,
-                                  clockid_t clock, uint64_t usec,
-                                  uint64_t accuracy,
-                                  sd_event_time_handler_t callback,
-                                  void* userdata) const = 0;
+    virtual int sd_event_add_time(
+        sd_event* event, sd_event_source** source, clockid_t clock,
+        uint64_t usec, uint64_t accuracy, sd_event_time_handler_t callback,
+        void* userdata) const = 0;
     virtual int sd_event_add_signal(sd_event* event, sd_event_source** source,
                                     int sig, sd_event_signal_handler_t callback,
                                     void* userdata) const = 0;
-    virtual int sd_event_add_child(sd_event* event, sd_event_source** source,
-                                   pid_t, int options,
-                                   sd_event_child_handler_t callback,
-                                   void* userdata) const = 0;
+    virtual int sd_event_add_child(
+        sd_event* event, sd_event_source** source, pid_t, int options,
+        sd_event_child_handler_t callback, void* userdata) const = 0;
     virtual int sd_event_add_defer(sd_event* event, sd_event_source** source,
                                    sd_event_handler_t callback,
                                    void* userdata) const = 0;
@@ -69,15 +67,12 @@
     virtual void* sd_event_source_set_userdata(sd_event_source* source,
                                                void* userdata) const = 0;
 
-    virtual int
-        sd_event_source_get_description(sd_event_source* source,
-                                        const char** description) const = 0;
-    virtual int
-        sd_event_source_set_description(sd_event_source* source,
-                                        const char* description) const = 0;
-    virtual int
-        sd_event_source_set_prepare(sd_event_source* source,
-                                    sd_event_handler_t callback) const = 0;
+    virtual int sd_event_source_get_description(
+        sd_event_source* source, const char** description) const = 0;
+    virtual int sd_event_source_set_description(
+        sd_event_source* source, const char* description) const = 0;
+    virtual int sd_event_source_set_prepare(
+        sd_event_source* source, sd_event_handler_t callback) const = 0;
     virtual int sd_event_source_get_pending(sd_event_source* source) const = 0;
     virtual int sd_event_source_get_priority(sd_event_source* source,
                                              int64_t* priority) const = 0;
diff --git a/src/sdeventplus/source/base.cpp b/src/sdeventplus/source/base.cpp
index 4975d69..75d759c 100644
--- a/src/sdeventplus/source/base.cpp
+++ b/src/sdeventplus/source/base.cpp
@@ -157,8 +157,8 @@
 
 int Base::prepareCallback(sd_event_source* source, void* userdata)
 {
-    return sourceCallback<Callback, Base, &Base::get_prepare>("prepareCallback",
-                                                              source, userdata);
+    return sourceCallback<Callback, Base, &Base::get_prepare>(
+        "prepareCallback", source, userdata);
 }
 
 namespace detail
diff --git a/src/sdeventplus/source/event.cpp b/src/sdeventplus/source/event.cpp
index 64601ca..c0730e3 100644
--- a/src/sdeventplus/source/event.cpp
+++ b/src/sdeventplus/source/event.cpp
@@ -59,8 +59,8 @@
 
 EventBaseData::EventBaseData(const EventBase& base,
                              EventBase::Callback&& callback) :
-    EventBase(base, sdeventplus::internal::NoOwn()),
-    BaseData(base), callback(std::move(callback))
+    EventBase(base, sdeventplus::internal::NoOwn()), BaseData(base),
+    callback(std::move(callback))
 {}
 
 } // namespace detail
diff --git a/src/sdeventplus/source/time.cpp b/src/sdeventplus/source/time.cpp
index 956bd67..d26174b 100644
--- a/src/sdeventplus/source/time.cpp
+++ b/src/sdeventplus/source/time.cpp
@@ -87,12 +87,12 @@
                                          Accuracy accuracy)
 {
     sd_event_source* source;
-    SDEVENTPLUS_CHECK("sd_event_add_time",
-                      event.getSdEvent()->sd_event_add_time(
-                          event.get(), &source, static_cast<clockid_t>(Id),
-                          SdEventDuration(time.time_since_epoch()).count(),
-                          SdEventDuration(accuracy).count(), timeCallback,
-                          nullptr));
+    SDEVENTPLUS_CHECK(
+        "sd_event_add_time",
+        event.getSdEvent()->sd_event_add_time(
+            event.get(), &source, static_cast<clockid_t>(Id),
+            SdEventDuration(time.time_since_epoch()).count(),
+            SdEventDuration(accuracy).count(), timeCallback, nullptr));
     return source;
 }
 
@@ -116,8 +116,8 @@
 template <ClockId Id>
 TimeData<Id>::TimeData(const Time<Id>& base,
                        typename Time<Id>::Callback&& callback) :
-    Time<Id>(base, sdeventplus::internal::NoOwn()),
-    BaseData(base), callback(std::move(callback))
+    Time<Id>(base, sdeventplus::internal::NoOwn()), BaseData(base),
+    callback(std::move(callback))
 {}
 
 } // namespace detail
diff --git a/src/sdeventplus/utility/timer.cpp b/src/sdeventplus/utility/timer.cpp
index 5398cec..1e49d9b 100644
--- a/src/sdeventplus/utility/timer.cpp
+++ b/src/sdeventplus/utility/timer.cpp
@@ -104,8 +104,8 @@
     {
         throw std::runtime_error("Timer was never initialized");
     }
-    timeSource.set_enabled(enabled ? source::Enabled::On
-                                   : source::Enabled::Off);
+    timeSource.set_enabled(
+        enabled ? source::Enabled::On : source::Enabled::Off);
 }
 
 template <ClockId Id>
@@ -189,9 +189,8 @@
 TimerData<Id>::TimerData(const Timer<Id>& base,
                          typename Timer<Id>::Callback&& callback,
                          std::optional<typename Timer<Id>::Duration> interval) :
-    Timer<Id>(base, sdeventplus::internal::NoOwn()),
-    expired(false), initialized(interval.has_value()),
-    callback(std::move(callback)),
+    Timer<Id>(base, sdeventplus::internal::NoOwn()), expired(false),
+    initialized(interval.has_value()), callback(std::move(callback)),
     clock(Event(base.timeSource.get_event(), sdeventplus::internal::NoOwn())),
     interval(interval)
 {}
diff --git a/test/event.cpp b/test/event.cpp
index b6f5699..9f814cc 100644
--- a/test/event.cpp
+++ b/test/event.cpp
@@ -120,8 +120,8 @@
 
     void SetUp()
     {
-        event = std::make_unique<Event>(expected_event, std::false_type(),
-                                        &mock);
+        event =
+            std::make_unique<Event>(expected_event, std::false_type(), &mock);
     }
 
     void TearDown()
diff --git a/test/source/base.cpp b/test/source/base.cpp
index f192546..369d6e5 100644
--- a/test/source/base.cpp
+++ b/test/source/base.cpp
@@ -56,8 +56,7 @@
 };
 
 BaseImpl::BaseImpl(const Event& event, sd_event_source* source,
-                   std::false_type) :
-    Base(event, source, std::false_type())
+                   std::false_type) : Base(event, source, std::false_type())
 {
     set_userdata(std::make_unique<BaseImplData>(*this));
 }
@@ -196,8 +195,8 @@
                     sd_event_source_set_userdata(expected_source, testing::_))
             .WillOnce(DoAll(SaveArg<1>(&userdata), Return(nullptr)));
     }
-    auto source = std::make_unique<BaseImpl>(*event, expected_source,
-                                             std::false_type());
+    auto source =
+        std::make_unique<BaseImpl>(*event, expected_source, std::false_type());
     EXPECT_CALL(mock, sd_event_source_get_userdata(expected_source))
         .WillRepeatedly(Return(userdata));
     EXPECT_FALSE(source->get_prepare());
diff --git a/test/source/io.cpp b/test/source/io.cpp
index 2a05d1e..ffb4fa6 100644
--- a/test/source/io.cpp
+++ b/test/source/io.cpp
@@ -153,8 +153,8 @@
             EXPECT_CALL(mock, sd_event_source_get_userdata(expected_source))
                 .WillRepeatedly(ReturnPointee(&userdata));
         }
-        io = std::make_unique<IO>(*event, fd, events,
-                                  [](IO&, int, uint32_t) {});
+        io =
+            std::make_unique<IO>(*event, fd, events, [](IO&, int, uint32_t) {});
     }
 
     void TearDown()
diff --git a/test/source/signal.cpp b/test/source/signal.cpp
index 4c95f3a..f04486b 100644
--- a/test/source/signal.cpp
+++ b/test/source/signal.cpp
@@ -84,11 +84,11 @@
     }
     int completions = 0;
     const struct signalfd_siginfo* return_si;
-    Signal::Callback callback = [&](Signal&,
-                                    const struct signalfd_siginfo* si) {
-        return_si = si;
-        completions++;
-    };
+    Signal::Callback callback =
+        [&](Signal&, const struct signalfd_siginfo* si) {
+            return_si = si;
+            completions++;
+        };
     Signal signal(*event, sig, std::move(callback));
     EXPECT_FALSE(callback);
     EXPECT_NE(&signal, userdata);
@@ -116,10 +116,10 @@
                                           testing::_, nullptr))
         .WillOnce(Return(-EINVAL));
     int completions = 0;
-    Signal::Callback callback = [&completions](Signal&,
-                                               const struct signalfd_siginfo*) {
-        completions++;
-    };
+    Signal::Callback callback =
+        [&completions](Signal&, const struct signalfd_siginfo*) {
+            completions++;
+        };
     EXPECT_THROW(Signal(*event, sig, std::move(callback)), SdEventError);
     EXPECT_TRUE(callback);
     EXPECT_EQ(0, completions);
diff --git a/test/source/time.cpp b/test/source/time.cpp
index 44b8228..60b7b9e 100644
--- a/test/source/time.cpp
+++ b/test/source/time.cpp
@@ -63,10 +63,10 @@
     const Time<id>::TimePoint expected_time(std::chrono::seconds{2});
     const Time<id>::Accuracy expected_accuracy(std::chrono::milliseconds{50});
     Time<id>::TimePoint saved_time;
-    Time<id>::Callback callback = [&saved_time](Time<id>&,
-                                                Time<id>::TimePoint time) {
-        saved_time = time;
-    };
+    Time<id>::Callback callback =
+        [&saved_time](Time<id>&, Time<id>::TimePoint time) {
+            saved_time = time;
+        };
 
     EXPECT_CALL(mock, sd_event_ref(expected_event))
         .WillOnce(Return(expected_event));
@@ -120,9 +120,9 @@
                 sd_event_add_time(expected_event, testing::_, CLOCK_MONOTONIC,
                                   2000000, 50000, testing::_, nullptr))
         .WillOnce(Return(-ENOSYS));
-    EXPECT_THROW(
-        Time<id>(*event, expected_time, expected_accuracy, std::move(callback)),
-        SdEventError);
+    EXPECT_THROW(Time<id>(*event, expected_time, expected_accuracy,
+                          std::move(callback)),
+                 SdEventError);
     EXPECT_TRUE(callback);
 }