Move bus_error to dbus-common and remove bus_error_message_or_strerror

bus_error and bus_error_message_or_strerror dit almost exactly the same,
so use only one of them and place it in dbus-common.
This commit is contained in:
Simon Peeters
2013-04-18 02:54:58 +02:00
committed by Lennart Poettering
parent 951657bd0a
commit 449101fce2
12 changed files with 13 additions and 26 deletions
-13
View File
@@ -21,9 +21,6 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <string.h>
#include <dbus/dbus.h>
#define BUS_ERROR_NO_SUCH_UNIT "org.freedesktop.systemd1.NoSuchUnit"
#define BUS_ERROR_NO_SUCH_JOB "org.freedesktop.systemd1.NoSuchJob"
#define BUS_ERROR_NOT_SUBSCRIBED "org.freedesktop.systemd1.NotSubscribed"
@@ -43,13 +40,3 @@
#define BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC "org.freedesktop.systemd1.TransactionOrderIsCyclic"
#define BUS_ERROR_SHUTTING_DOWN "org.freedesktop.systemd1.ShuttingDown"
#define BUS_ERROR_NO_SUCH_PROCESS "org.freedesktop.systemd1.NoSuchProcess"
static inline const char *bus_error(const DBusError *e, int r) {
if (e && e->message)
return e->message;
if (r >= 0)
return strerror(r);
return strerror(-r);
}
+1 -1
View File
@@ -46,7 +46,7 @@
#include "missing.h"
#include "unit-name.h"
#include "unit-printf.h"
#include "bus-errors.h"
#include "dbus-common.h"
#include "utf8.h"
#include "path-util.h"
#include "syscall-list.h"
+1 -1
View File
@@ -40,7 +40,7 @@
#include "fdset.h"
#include "special.h"
#include "conf-parser.h"
#include "bus-errors.h"
#include "dbus-common.h"
#include "missing.h"
#include "label.h"
#include "build.h"
+1 -1
View File
@@ -31,7 +31,7 @@
#include "mkdir.h"
#include "dbus-path.h"
#include "special.h"
#include "bus-errors.h"
#include "dbus-common.h"
#include "path-util.h"
#include "macro.h"
+1 -1
View File
@@ -36,7 +36,7 @@
#include "unit-printf.h"
#include "dbus-service.h"
#include "special.h"
#include "bus-errors.h"
#include "dbus-common.h"
#include "exit-status.h"
#include "def.h"
#include "path-util.h"
+1 -1
View File
@@ -46,7 +46,7 @@
#include "dbus-socket.h"
#include "missing.h"
#include "special.h"
#include "bus-errors.h"
#include "dbus-common.h"
#include "label.h"
#include "exit-status.h"
#include "def.h"
+1 -1
View File
@@ -26,7 +26,7 @@
#include "timer.h"
#include "dbus-timer.h"
#include "special.h"
#include "bus-errors.h"
#include "dbus-common.h"
static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = {
[TIMER_DEAD] = UNIT_INACTIVE,
+1
View File
@@ -24,6 +24,7 @@
#include "transaction.h"
#include "bus-errors.h"
#include "dbus-common.h"
static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
+2 -2
View File
@@ -251,7 +251,7 @@ int main(int argc, char *argv[]) {
r = print_inhibitors(bus, &error);
if (r < 0) {
log_error("Failed to list inhibitors: %s", bus_error_message_or_strerror(&error, -r));
log_error("Failed to list inhibitors: %s", bus_error(&error, r));
goto finish;
}
@@ -266,7 +266,7 @@ int main(int argc, char *argv[]) {
free(w);
if (fd < 0) {
log_error("Failed to inhibit: %s", bus_error_message_or_strerror(&error, -r));
log_error("Failed to inhibit: %s", bus_error(&error, r));
r = fd;
goto finish;
}
+1 -1
View File
@@ -2457,7 +2457,7 @@ int manager_dispatch_delayed(Manager *manager) {
dbus_error_init(&error);
r = execute_shutdown_or_sleep(manager, manager->action_what, manager->action_unit, &error);
if (r < 0) {
log_warning("Failed to send delayed message: %s", bus_error_message_or_strerror(&error, -r));
log_warning("Failed to send delayed message: %s", bus_error(&error, r));
dbus_error_free(&error);
manager->action_unit = NULL;
+2 -3
View File
@@ -258,12 +258,11 @@ const char *bus_error_message(const DBusError *error) {
return error->message;
}
const char *bus_error_message_or_strerror(const DBusError *error, int err) {
const char *bus_error(const DBusError *error, int err) {
if (error && dbus_error_is_set(error))
return bus_error_message(error);
return strerror(err);
return strerror(err < 0 ? -err : err);
}
DBusHandlerResult bus_default_message_handler(
+1 -1
View File
@@ -92,7 +92,7 @@ int bus_connect_system_ssh(const char *user, const char *host, DBusConnection **
int bus_connect_system_polkit(DBusConnection **_bus, DBusError *error);
const char *bus_error_message(const DBusError *error);
const char *bus_error_message_or_strerror(const DBusError *error, int err);
const char *bus_error(const DBusError *e, int r);
typedef int (*BusPropertyCallback)(DBusMessageIter *iter, const char *property, void *data);
typedef int (*BusPropertySetCallback)(DBusMessageIter *iter, const char *property, void *data);