main: use sdeventplus
Make use of the RAII that comes with the sdeventplus c++ bindings for
the sd_event library.
Change-Id: Ie655766fdc625e1150c956b2eb16e0352e7c3859
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/item_updater_main.cpp b/item_updater_main.cpp
index 69ee015..0e4a35b 100644
--- a/item_updater_main.cpp
+++ b/item_updater_main.cpp
@@ -12,6 +12,7 @@
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/manager.hpp>
+#include <sdeventplus/event.hpp>
#include <system_error>
@@ -20,15 +21,7 @@
using namespace openpower::software::updater;
using namespace phosphor::logging;
auto bus = sdbusplus::bus::new_default();
-
- sd_event* loop = nullptr;
- auto rc = sd_event_default(&loop);
- if (rc < 0)
- {
- log<level::ERR>("Error occurred during the sd_event_default",
- entry("RC=%d", rc));
- return -1;
- }
+ auto loop = sdeventplus::Event::get_default();
// Add sdbusplus ObjectManager.
sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH);
@@ -46,12 +39,12 @@
{
#ifdef UBIFS_LAYOUT
openpower::software::updater::Watch watch(
- loop,
+ loop.get(),
std::bind(std::mem_fn(&ItemUpdater::updateFunctionalAssociation),
&updater, std::placeholders::_1));
#endif
- bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
- rc = sd_event_loop(loop);
+ bus.attach_event(loop.get(), SD_EVENT_PRIORITY_NORMAL);
+ auto rc = loop.loop();
if (rc < 0)
{
log<level::ERR>("Error occurred during the sd_event_loop",
@@ -65,7 +58,5 @@
return -1;
}
- sd_event_unref(loop);
-
return 0;
}