summaryrefslogtreecommitdiffstats
path: root/sdevent
diff options
context:
space:
mode:
Diffstat (limited to 'sdevent')
-rw-r--r--sdevent/event.hpp32
-rw-r--r--sdevent/source.hpp22
2 files changed, 45 insertions, 9 deletions
diff --git a/sdevent/event.hpp b/sdevent/event.hpp
index 9f04dd0..53776ae 100644
--- a/sdevent/event.hpp
+++ b/sdevent/event.hpp
@@ -2,10 +2,11 @@
#include <chrono>
#include <memory>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
#include <sdbusplus/bus.hpp>
#include <systemd/sd-event.h>
-
-// TODO: openbmc/openbmc#1720 - add error handling for sd_event API failures
+#include <xyz/openbmc_project/Common/error.hpp>
namespace sdevent
{
@@ -46,6 +47,10 @@ using Event = std::unique_ptr<sd_event, EventDeleter>;
*/
class Event
{
+ private:
+ using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
+
public:
/* Define all of the basic class operations:
* Not allowed:
@@ -84,7 +89,11 @@ class Event
/** @brief Wait indefinitely for new event sources. */
void loop()
{
- sd_event_loop(evt.get());
+ auto rc = sd_event_loop(evt.get());
+ if (rc < 0)
+ {
+ phosphor::logging::elog<InternalFailure>();
+ }
}
/** @brief Stop the loop. */
@@ -122,7 +131,12 @@ class Event
using namespace std::chrono;
uint64_t usec;
- sd_event_now(evt.get(), CLOCK_MONOTONIC, &usec);
+ auto rc = sd_event_now(evt.get(), CLOCK_MONOTONIC, &usec);
+ if (rc < 0)
+ {
+ phosphor::logging::elog<InternalFailure>();
+ }
+
microseconds d(usec);
return steady_clock::time_point(d);
}
@@ -151,8 +165,16 @@ inline Event::Event(EventPtr l, std::false_type) : evt(l)
inline Event newDefault()
{
+ using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
+
sd_event* e = nullptr;
- sd_event_default(&e);
+ auto rc = sd_event_default(&e);
+ if (rc < 0)
+ {
+ phosphor::logging::elog<InternalFailure>();
+ }
+
return Event(e, std::false_type());
}
diff --git a/sdevent/source.hpp b/sdevent/source.hpp
index e9e2a0c..be3a892 100644
--- a/sdevent/source.hpp
+++ b/sdevent/source.hpp
@@ -1,9 +1,10 @@
#pragma once
#include <memory>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
#include <systemd/sd-event.h>
-
-// TODO: openbmc/openbmc#1720 - add error handling for sd_event API failures
+#include <xyz/openbmc_project/Common/error.hpp>
namespace sdevent
{
@@ -36,6 +37,10 @@ using source = std::unique_ptr<sd_event_source, SourceDeleter>;
*/
class Source
{
+ private:
+ using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
+
public:
/* Define all of the basic class operations:
* Not allowed:
@@ -75,14 +80,23 @@ class Source
auto enabled()
{
int enabled;
- sd_event_source_get_enabled(src.get(), &enabled);
+ auto rc = sd_event_source_get_enabled(src.get(), &enabled);
+ if (rc < 0)
+ {
+ phosphor::logging::elog<InternalFailure>();
+ }
+
return enabled;
}
/** @brief Allow the source to generate events. */
void enable(int enable)
{
- sd_event_source_set_enabled(src.get(), enable);
+ auto rc = sd_event_source_set_enabled(src.get(), enable);
+ if (rc < 0)
+ {
+ phosphor::logging::elog<InternalFailure>();
+ }
}
private:
OpenPOWER on IntegriCloud