tree-wide: Use get() helper instead of direct access
This makes it easier to refactor the handle used to hold the pointers.
Change-Id: Ie6eaf9cab998039f18d61a6321774a3db3fa5564
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/sdeventplus/event.cpp b/src/sdeventplus/event.cpp
index 64dc7ee..946d34c 100644
--- a/src/sdeventplus/event.cpp
+++ b/src/sdeventplus/event.cpp
@@ -56,7 +56,7 @@
int Event::prepare() const
{
- int r = sdevent->sd_event_prepare(event.get());
+ int r = sdevent->sd_event_prepare(get());
if (r < 0)
{
throw SdEventError(-r, "sd_event_prepare");
@@ -68,7 +68,7 @@
{
// An unsigned -1 timeout value means infinity in sd_event
uint64_t timeout_usec = timeout ? timeout->count() : -1;
- int r = sdevent->sd_event_wait(event.get(), timeout_usec);
+ int r = sdevent->sd_event_wait(get(), timeout_usec);
if (r < 0)
{
throw SdEventError(-r, "sd_event_wait");
@@ -78,7 +78,7 @@
int Event::dispatch() const
{
- int r = sdevent->sd_event_dispatch(event.get());
+ int r = sdevent->sd_event_dispatch(get());
if (r < 0)
{
throw SdEventError(-r, "sd_event_dispatch");
@@ -90,7 +90,7 @@
{
// An unsigned -1 timeout value means infinity in sd_event
uint64_t timeout_usec = timeout ? timeout->count() : -1;
- int r = sdevent->sd_event_run(event.get(), timeout_usec);
+ int r = sdevent->sd_event_run(get(), timeout_usec);
if (r < 0)
{
throw SdEventError(-r, "sd_event_run");
@@ -100,7 +100,7 @@
int Event::loop() const
{
- int r = sdevent->sd_event_loop(event.get());
+ int r = sdevent->sd_event_loop(get());
if (r < 0)
{
throw SdEventError(-r, "sd_event_loop");
@@ -110,7 +110,7 @@
void Event::exit(int code) const
{
- int r = sdevent->sd_event_exit(event.get(), code);
+ int r = sdevent->sd_event_exit(get(), code);
if (r < 0)
{
throw SdEventError(-r, "sd_event_exit");
@@ -120,7 +120,7 @@
int Event::get_exit_code() const
{
int code;
- int r = sdevent->sd_event_get_exit_code(event.get(), &code);
+ int r = sdevent->sd_event_get_exit_code(get(), &code);
if (r < 0)
{
throw SdEventError(-r, "sd_event_get_exit_code");
@@ -130,7 +130,7 @@
bool Event::get_watchdog() const
{
- int r = sdevent->sd_event_get_watchdog(event.get());
+ int r = sdevent->sd_event_get_watchdog(get());
if (r < 0)
{
throw SdEventError(-r, "sd_event_get_watchdog");
@@ -140,7 +140,7 @@
bool Event::set_watchdog(bool b) const
{
- int r = sdevent->sd_event_set_watchdog(event.get(), b);
+ int r = sdevent->sd_event_set_watchdog(get(), b);
if (r < 0)
{
throw SdEventError(-r, "sd_event_set_watchdog");
diff --git a/src/sdeventplus/source/base.cpp b/src/sdeventplus/source/base.cpp
index 9915132..81ea591 100644
--- a/src/sdeventplus/source/base.cpp
+++ b/src/sdeventplus/source/base.cpp
@@ -31,7 +31,7 @@
const char* Base::get_description() const
{
const char* description;
- int r = event.getSdEvent()->sd_event_source_get_description(source.get(),
+ int r = event.getSdEvent()->sd_event_source_get_description(get(),
&description);
if (r < 0)
{
@@ -42,8 +42,8 @@
void Base::set_description(const char* description) const
{
- int r = event.getSdEvent()->sd_event_source_set_description(source.get(),
- description);
+ int r =
+ event.getSdEvent()->sd_event_source_set_description(get(), description);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_set_description");
@@ -53,7 +53,7 @@
void Base::set_prepare(Callback&& callback)
{
int r = event.getSdEvent()->sd_event_source_set_prepare(
- source.get(), callback ? prepareCallback : nullptr);
+ get(), callback ? prepareCallback : nullptr);
if (r < 0)
{
prepare = nullptr;
@@ -69,7 +69,7 @@
bool Base::get_pending() const
{
- int r = event.getSdEvent()->sd_event_source_get_pending(source.get());
+ int r = event.getSdEvent()->sd_event_source_get_pending(get());
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_pending");
@@ -80,8 +80,7 @@
int64_t Base::get_priority() const
{
int64_t priority;
- int r = event.getSdEvent()->sd_event_source_get_priority(source.get(),
- &priority);
+ int r = event.getSdEvent()->sd_event_source_get_priority(get(), &priority);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_priority");
@@ -91,8 +90,7 @@
void Base::set_priority(int64_t priority) const
{
- int r = event.getSdEvent()->sd_event_source_set_priority(source.get(),
- priority);
+ int r = event.getSdEvent()->sd_event_source_set_priority(get(), priority);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_set_priority");
@@ -102,8 +100,7 @@
Enabled Base::get_enabled() const
{
int enabled;
- int r =
- event.getSdEvent()->sd_event_source_get_enabled(source.get(), &enabled);
+ int r = event.getSdEvent()->sd_event_source_get_enabled(get(), &enabled);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_enabled");
@@ -114,7 +111,7 @@
void Base::set_enabled(Enabled enabled) const
{
int r = event.getSdEvent()->sd_event_source_set_enabled(
- source.get(), static_cast<int>(enabled));
+ get(), static_cast<int>(enabled));
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_set_enabled");
@@ -172,7 +169,7 @@
void Base::set_userdata()
{
- event.getSdEvent()->sd_event_source_set_userdata(source.get(), this);
+ event.getSdEvent()->sd_event_source_set_userdata(get(), this);
}
} // namespace source
diff --git a/src/sdeventplus/source/child.cpp b/src/sdeventplus/source/child.cpp
index b549473..c7b02d9 100644
--- a/src/sdeventplus/source/child.cpp
+++ b/src/sdeventplus/source/child.cpp
@@ -22,8 +22,7 @@
pid_t Child::get_pid() const
{
pid_t pid;
- int r =
- event.getSdEvent()->sd_event_source_get_child_pid(source.get(), &pid);
+ int r = event.getSdEvent()->sd_event_source_get_child_pid(get(), &pid);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_child_pid");
diff --git a/src/sdeventplus/source/io.cpp b/src/sdeventplus/source/io.cpp
index 49583d0..d3aa83b 100644
--- a/src/sdeventplus/source/io.cpp
+++ b/src/sdeventplus/source/io.cpp
@@ -20,7 +20,7 @@
int IO::get_fd() const
{
- int r = event.getSdEvent()->sd_event_source_get_io_fd(source.get());
+ int r = event.getSdEvent()->sd_event_source_get_io_fd(get());
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_io_fd");
@@ -30,7 +30,7 @@
void IO::set_fd(int fd) const
{
- int r = event.getSdEvent()->sd_event_source_set_io_fd(source.get(), fd);
+ int r = event.getSdEvent()->sd_event_source_set_io_fd(get(), fd);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_set_io_fd");
@@ -40,8 +40,7 @@
uint32_t IO::get_events() const
{
uint32_t events;
- int r = event.getSdEvent()->sd_event_source_get_io_events(source.get(),
- &events);
+ int r = event.getSdEvent()->sd_event_source_get_io_events(get(), &events);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_io_events");
@@ -51,8 +50,7 @@
void IO::set_events(uint32_t events) const
{
- int r =
- event.getSdEvent()->sd_event_source_set_io_events(source.get(), events);
+ int r = event.getSdEvent()->sd_event_source_set_io_events(get(), events);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_set_io_events");
@@ -62,8 +60,7 @@
uint32_t IO::get_revents() const
{
uint32_t revents;
- int r = event.getSdEvent()->sd_event_source_get_io_revents(source.get(),
- &revents);
+ int r = event.getSdEvent()->sd_event_source_get_io_revents(get(), &revents);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_io_revents");
diff --git a/src/sdeventplus/source/signal.cpp b/src/sdeventplus/source/signal.cpp
index 98b1a05..b47d78d 100644
--- a/src/sdeventplus/source/signal.cpp
+++ b/src/sdeventplus/source/signal.cpp
@@ -21,7 +21,7 @@
int Signal::get_signal() const
{
- int r = event.getSdEvent()->sd_event_source_get_signal(source.get());
+ int r = event.getSdEvent()->sd_event_source_get_signal(get());
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_signal");
diff --git a/src/sdeventplus/source/time.cpp b/src/sdeventplus/source/time.cpp
index bbc3295..9d4f9ca 100644
--- a/src/sdeventplus/source/time.cpp
+++ b/src/sdeventplus/source/time.cpp
@@ -29,7 +29,7 @@
typename Time<Id>::TimePoint Time<Id>::get_time() const
{
uint64_t usec;
- int r = event.getSdEvent()->sd_event_source_get_time(source.get(), &usec);
+ int r = event.getSdEvent()->sd_event_source_get_time(get(), &usec);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_time");
@@ -41,7 +41,7 @@
void Time<Id>::set_time(TimePoint time) const
{
int r = event.getSdEvent()->sd_event_source_set_time(
- source.get(), SdEventDuration(time.time_since_epoch()).count());
+ get(), SdEventDuration(time.time_since_epoch()).count());
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_set_time");
@@ -52,8 +52,7 @@
typename Time<Id>::Accuracy Time<Id>::get_accuracy() const
{
uint64_t usec;
- int r = event.getSdEvent()->sd_event_source_get_time_accuracy(source.get(),
- &usec);
+ int r = event.getSdEvent()->sd_event_source_get_time_accuracy(get(), &usec);
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_get_time_accuracy");
@@ -65,7 +64,7 @@
void Time<Id>::set_accuracy(Accuracy accuracy) const
{
int r = event.getSdEvent()->sd_event_source_set_time_accuracy(
- source.get(), SdEventDuration(accuracy).count());
+ get(), SdEventDuration(accuracy).count());
if (r < 0)
{
throw SdEventError(-r, "sd_event_source_set_time_accuracy");