From: Michal Bloch Date: Wed, 5 Jan 2022 15:10:23 +0000 (+0100) Subject: libdbus-p2p: better error reporting X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F97%2F269297%2F1;p=platform%2Fcore%2Fsystem%2Fdbus-tools.git libdbus-p2p: better error reporting Change-Id: Ie172dcf45da6a2eb82f37cbb9a9eca7a31ebb4bf Signed-off-by: Michal Bloch --- diff --git a/benchmark/libdbus-p2p-server.cpp b/benchmark/libdbus-p2p-server.cpp index 0a80407..0540dfd 100644 --- a/benchmark/libdbus-p2p-server.cpp +++ b/benchmark/libdbus-p2p-server.cpp @@ -338,12 +338,22 @@ int main (int argc, char ** argv) return EXIT_FAILURE; } + DBusError derror; + dbus_error_init (& derror); + /* thread_local ensures the destructor runs, the destructor doesn't * run on std::exit without it as per the std::exit specification. * Otherwise it makes no difference since we're single-threaded. */ - thread_local std::unique_ptr server (dbus_server_listen (("unix:path=" + opt.sock_path).c_str(), nullptr)); + thread_local std::unique_ptr server (dbus_server_listen (("unix:path=" + opt.sock_path).c_str(), & derror)); if (!server) { - std::cerr << "listening on " << opt.sock_path << "failed" << std::endl; + + if (dbus_error_is_set (&derror)) { + std::cerr << derror.name << ": " << derror.message << std::endl; + dbus_error_free (&derror); // stack var is fine, doesn't actually free the memory + } else { + std::cerr << "listening on " << opt.sock_path << " failed (unknown error)" << std::endl; + } + return EXIT_FAILURE; }