AM_CFLAGS = \
-Wall \
+ -Werror \
-Wchar-subscripts \
-Wformat-security \
-Wmissing-declarations \
void epc_object_destroy(struct epc_object *obj);
int epc_object_append_new(struct epc_object *parent, const char *key,
- int type, void *val);
+ int type, const void *val);
int epc_object_append_string(struct epc_object *obj, const char *key,
const char *val);
#define DM_EV_ACTION_DATA "actd"
#define DM_EV_REASON "rsn"
-typedef void (*on_action_finished_cb)(struct action_executed_event *ev, int result);
+struct decision_made_event;
+
+typedef void (*on_action_finished_cb)(struct decision_made_event *ev, int result);
struct decision_made_event {
struct epc_event event;
{
struct unit_action_data *data = userdata;
char *job;
- int ret;
assert(data);
finish_action(data, 0, NULL);
}
-
-static int unit_action_handler(GVariant *var, void *userdata, GError *err)
+static void unit_action_handler(GVariant *var, void *userdata, GError *err)
{
struct unit_action_data *data = userdata;
dbus_handle_h bus;
int ret;
- char *s;
- if (err)
- return finish_action(data, -err->code, err->message);
+ if (err) {
+ finish_action(data, -err->code, err->message);
+ return;
+ }
if (!data)
- return -EINVAL;
+ return;
bus = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, 0);
- if (!bus)
- return finish_action(data, -EINVAL, "Could not acquire systemd bus");
+ if (!bus) {
+ finish_action(data, -EINVAL, "Could not acquire systemd bus");
+ return;
+ }
if (data->wait_for_unit) {
- ret = subscribe_dbus_signal(bus, NULL,
+ ret = subscribe_dbus_signal(bus,
"sender='org.freedesktop.systemd1",
"org.freedesktop.systemd1.Manager",
"JobRemoved",
on_job_removed,
- data);
+ data,
+ NULL);
if (ret < 0) {
- return finish_action(data, ret, "Could not register for JobRemoved signal");
+ finish_action(data, ret, "Could not register for JobRemoved signal");
+ return;
}
- return 0;
+ return;
}
- return finish_action(data, 0, NULL);
+ finish_action(data, 0, NULL);
+ return;
}
static int start_unit(struct epc_action *action,
g_variant_get(reply, "a(ssssssouso)", &iter);
while ((child = g_variant_iter_next_value(&iter))) {
- parse_unit_list(child, &name);
+ parse_unit_info(child, &name);
u = calloc(1, sizeof(*u));
if (!u) {
static void unit_control_executed(struct decision_made_event *dm_ev, int result)
{
struct unit_control_event *event = to_unit_control_event(dm_ev->reason);
- int ret;
if (result < 0)
event->err_code = result;
#include <gio/gio.h>
#include <errno.h>
#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
#include "unit_control.h"
};
struct generic_user_data {
+ GDBusConnection *bus;
actd_unit_cb cb;
void *user_data;
int call_type;
if (!data)
return;
- var = g_dbus_connection_call_finish(source_object, res, &err);
+ var = g_dbus_connection_call_finish(data->bus, res, &err);
if (err && err->code == G_IO_ERROR_TIMED_OUT) {
status = UNIT_CONTROL_TIMEOUT;
free(data);
}
-const char *translate_to_systemd(const char *method)
+static const char *translate_to_systemd(const char *method)
{
if (strcmp(method, "Start") == 0)
return "StartUnit";
goto out;
} else {
/* we assume that activationd runs on system bus and can be used as a proxy */
- const char *result = NULL;
+ char *result = NULL;
msg = g_dbus_connection_call_sync(bus,
UNIT_CONTROL_NAME,
data->user_data = user_data;
data->cb = cb;
+ data->bus = bus;
if (bus_type == G_BUS_TYPE_SESSION) {
data->call_type = CALL_TYPE_SYSTEMD;
#define ACTD_DBUS_API_SERVICE_NAME "org.tizen.activationd"
#define ACTD_DBUS_API_OBJECT_PATH "/org/tizen/activationd"
-static int method_generic_callback(GVariant *param, GDBusMethodInvocation *invocation,
+#define STRING_VARIANT ((const GVariantType *) "(s)")
+
+static GVariant *method_generic_callback(GVariant *param, GDBusMethodInvocation *invocation,
void *userdata, const char *method)
{
int r;
goto fail;
}
- if (!g_variant_is_of_type(param, "(s)")) {
+ if (!g_variant_is_of_type(param, STRING_VARIANT)) {
log_error("Invalid parameter type passed to %s method. "
"Expected: (s), got: %s\n", method, g_variant_get_type_string(param));
r = -EINVAL;
return NULL;
}
-static inline void copy_obj_val(struct epc_object *obj, void *val)
+static inline void copy_obj_val(struct epc_object *obj, const void *val)
{
memcpy(&obj->val, val, data_size[obj->type]);
}
free(obj);
}
-static inline void init_obj(struct epc_object *obj, int type, void *val)
+static inline void init_obj(struct epc_object *obj, int type, const void *val)
{
assert(val != NULL || type == TYPE_OBJECT);
copy_obj_val(obj, val);
}
-static struct epc_object *new_object_node(int type, void *val)
+static struct epc_object *new_object_node(int type, const void *val)
{
struct epc_object *obj;
}
int epc_object_append_new(struct epc_object *parent, const char *key,
- int type, void *val)
+ int type, const void *val)
{
struct epc_object *child;
int ret;
void *user_data, char *types, ...)
{
dbus_handle_h bus = NULL;
- int ret;
GVariant *var = NULL;
bus = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, 0);
char *types, ...)
{
dbus_handle_h bus = NULL;
- int ret;
GVariant *var = NULL;
bus = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, 0);
GMainLoop *loop;
guint func_timeout, test_timeout;
int result;
- int (*func_sync)(GBusType bus_type, const char *unit, int timeout);
- int (*func_async)(GBusType bus_type, const char *unit, actd_unit_cb cb, void *user_data, int timeout);
+ int (*func_sync)(BusType bus_type, const char *unit, int timeout);
+ int (*func_async)(BusType bus_type, const char *unit, actd_unit_cb cb, void *user_data, int timeout);
};
struct unit_test {
int (*func)(struct context *);
};
-int translate_unit_state(const gchar *value)
+static int translate_unit_state(const gchar *value)
{
if (!g_strcmp0(value, "active"))
return UNIT_ON;
}
-int get_unit_state(GVariant *dictionary)
+static int get_unit_state(GVariant *dictionary)
{
GVariantIter iter;
GVariant *value;
{
GVariantIter iter;
GVariant *child;
- gchar *key;
int state;
struct context *ctx = (struct context *)user_data;
}
}
-GDBusConnection *get_bus(GBusType bus_type)
+static GDBusConnection *get_bus(GBusType bus_type)
{
GDBusConnection *bus = NULL;
bus = g_bus_get_sync(bus_type, NULL, NULL);
G_DBUS_SIGNAL_FLAGS_NONE,
on_properties_changed,
(gpointer)ctx,
- &error
+ NULL
);
if (ctx->subscription_id == 0) {
printf("signal subscription error: %s\n", error->message);
return ctx->subscription_id;
}
-gboolean test_timeout(gpointer user_data)
+static gboolean test_timeout(gpointer user_data)
{
struct context *ctx = (struct context *)user_data;
return FALSE;
}
-gboolean func_start(gpointer user_data)
+static gboolean func_start(gpointer user_data)
{
struct context *ctx = (struct context *)user_data;
int ret = ctx->func_sync(ctx->bus_type, TEST_SERVICE, UNIT_CONTROL_TIMEOUT_DEFAULT);
return FALSE;
}
-int test_sync_action(struct context *ctx)
+static int test_sync_action(struct context *ctx)
{
assert(ctx);
return ctx->result;
}
-int test_unit_start(struct context *ctx)
+static int test_unit_start(struct context *ctx)
{
assert(ctx);
return test_sync_action(ctx);
}
-int test_unit_stop(struct context *ctx)
+static int test_unit_stop(struct context *ctx)
{
assert(ctx);
return test_sync_action(ctx);
}
-int test_unit_restart(struct context *ctx)
+static int test_unit_restart(struct context *ctx)
{
assert(ctx);
return test_sync_action(ctx);
}
-void handler(int status, void *user_data, GError *err)
+static void handler(int status, void *user_data)
{
struct context *ctx = (struct context *)user_data;
ctx->result = status;
g_main_loop_quit(ctx->loop);
}
-int test_async_action(struct context *ctx)
+static int test_async_action(struct context *ctx)
{
assert(ctx);
assert(ctx->func_async);
return ctx->result;
}
-int test_unit_start_async(struct context *ctx)
+static int test_unit_start_async(struct context *ctx)
{
assert(ctx);
return test_async_action(ctx);
}
-int test_unit_stop_async(struct context *ctx)
+static int test_unit_stop_async(struct context *ctx)
{
ctx->unit_state[0] = UNIT_OFF;
ctx->unit_state_pos = 0;
return test_async_action(ctx);
}
-int test_unit_restart_async(struct context *ctx)
+static int test_unit_restart_async(struct context *ctx)
{
ctx->unit_state[0] = UNIT_OFF;
ctx->unit_state[1] = UNIT_ON;
}
}
-void test(GBusType bus_type, struct unit_test tests[])
+static void test(GBusType bus_type, struct unit_test tests[])
{
assert(bus_type == G_BUS_TYPE_SYSTEM || bus_type == G_BUS_TYPE_SESSION);
int ret;
return;
}
-int main()
+int main(int argc, char *argv[])
{
struct unit_test tests[] = {
{"UnitStart", test_unit_start},