From d078a5c04bec4502ccfa093eb4e59729a01efdf9 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 8 Feb 2019 15:57:05 +0900 Subject: [PATCH] Add dlog for debugging and fix build warnings Change-Id: Idad13056a15185a622f51283589af7bedf5734df Signed-off-by: lokilee73 --- packaging/libsyscommon.spec | 1 + src/libgdbus/CMakeLists.txt | 1 + src/libgdbus/dbus-system.c | 3 +-- src/libgdbus/dbus-system.h | 1 + src/libgdbus/dbus-systemd.c | 27 +++------------------------ 5 files changed, 7 insertions(+), 26 deletions(-) diff --git a/packaging/libsyscommon.spec b/packaging/libsyscommon.spec index fb7114f..57175d4 100644 --- a/packaging/libsyscommon.spec +++ b/packaging/libsyscommon.spec @@ -12,6 +12,7 @@ Source1001: %{name}.manifest BuildRequires: pkgconfig(glib-2.0) >= 2.44 BuildRequires: pkgconfig(gio-2.0) >= 2.44 BuildRequires: pkgconfig(gio-unix-2.0) +BuildRequires: pkgconfig(dlog) BuildRequires: cmake Requires: /bin/cp diff --git a/src/libgdbus/CMakeLists.txt b/src/libgdbus/CMakeLists.txt index 06f1bc2..9baa020 100644 --- a/src/libgdbus/CMakeLists.txt +++ b/src/libgdbus/CMakeLists.txt @@ -21,6 +21,7 @@ INCLUDE(FindPkgConfig) pkg_check_modules(gdbus REQUIRED glib-2.0 gio-2.0 + dlog gio-unix-2.0) FOREACH(flag ${gdbus_CFLAGS}) diff --git a/src/libgdbus/dbus-system.c b/src/libgdbus/dbus-system.c index e59da08..7ed53ba 100644 --- a/src/libgdbus/dbus-system.c +++ b/src/libgdbus/dbus-system.c @@ -1557,7 +1557,7 @@ sig_ctx *dbus_handle_new_signal_ctx(void) } ctx->timeout_src = NULL; ctx->param = NULL; - ctx->quit_reason = 0; + ctx->quit_reason = CTX_QUIT_UNKNOWN; ctx->user_data = NULL; return ctx; @@ -1618,7 +1618,6 @@ static gboolean _cb_ctx_timeout(gpointer user_data) int dbus_handle_signal_ctx_add_timeout(sig_ctx *ctx, int timeout_msec) { GSource *src = NULL; - guint id = 0; if (!ctx) return -EINVAL; diff --git a/src/libgdbus/dbus-system.h b/src/libgdbus/dbus-system.h index ef5ba75..6cdec69 100644 --- a/src/libgdbus/dbus-system.h +++ b/src/libgdbus/dbus-system.h @@ -496,6 +496,7 @@ typedef struct { sig_ctx *dbus_handle_new_signal_ctx(void); void dbus_handle_free_signal_ctx(sig_ctx *ctx); guint subscribe_dbus_signal_ctx(dbus_handle_h handle, sig_ctx *ctx, const char *sender, const char *path, const char *iface, const char *name, GDBusSignalCallback cb); +int dbus_handle_signal_ctx_wait(sig_ctx *ctx); int dbus_handle_signal_ctx_add_timeout(sig_ctx *ctx, int timeout); GVariant *dbus_handle_make_simple_array(const char *sig, int *param); diff --git a/src/libgdbus/dbus-systemd.c b/src/libgdbus/dbus-systemd.c index 998468d..b06e2fa 100644 --- a/src/libgdbus/dbus-systemd.c +++ b/src/libgdbus/dbus-systemd.c @@ -51,8 +51,8 @@ #define UNIT_NAME_MAX 256 typedef struct { - char *job_id; - char *unit_name; + const char *job_id; + const char *unit_name; } unitinfo; static void _cb_JobRemoved(GDBusConnection *conn, @@ -108,7 +108,6 @@ static int _systemd_control_unit_sync(const char *method, const char *name, int gchar *objpath = NULL; int ret = 0; sig_ctx *ctx = NULL; - gchar *unit_name = NULL; unitinfo uinfo; int quit_reason; @@ -118,7 +117,7 @@ static int _systemd_control_unit_sync(const char *method, const char *name, int _I("Starting: %s %s", method, name); - /* synchronous siganl subscriptsion */ + /* synchronous signal subscription */ ret = subscribe_dbus_signal_ctx(NULL, ctx, SYSTEMD_DBUS_SERVICE, SYSTEMD_DBUS_PATH, SYSTEMD_DBUS_IFACE_MANAGER, "JobRemoved", _cb_JobRemoved); if (ret == 0) { ret = -1; @@ -158,9 +157,6 @@ static int _systemd_control_unit_sync(const char *method, const char *name, int _I("Finished: %s %s", method, name); finish: - if (unit_name) - g_free(unit_name); - if (reply) g_variant_unref(reply); g_free(objpath); @@ -199,22 +195,6 @@ finish: return ret; } -static int _has_suffix(const char *service_name, const char *suffix) -{ - int index = 0; - - if (!service_name || !suffix) - return FALSE; - - index = strlen(service_name) - strlen(suffix); - if (index <= 0) - return FALSE; - - if (strcmp(service_name + index, suffix) == 0) - return TRUE; - return FALSE; -} - static int _change_suffix(const char *name, const char *suffix, char **new_name) { char *buf = NULL; @@ -301,7 +281,6 @@ Returns: the exit status static int _systemd_start_unit_internal(const char *name, const char *suffix, int timeout_msec, const char *method, int sync) { - unsigned int len = 0; char *new_name = NULL; int ret = 0; -- 2.7.4