g_kdbus_free_data (GKDBusWorker *kdbus,
guint64 offset)
{
- struct kdbus_cmd_free cmd = {};
+ struct kdbus_cmd_free cmd = {
+ .size = sizeof(cmd),
+ .offset = offset,
+ .flags = 0
+ };
int ret;
- cmd.size = sizeof(cmd);
- cmd.offset = offset;
- cmd.flags = 0;
-
ret = ioctl (kdbus->fd, KDBUS_CMD_FREE, &cmd);
if (ret < 0)
return FALSE;
_g_kdbus_Hello (GKDBusWorker *worker,
GError **error)
{
- struct kdbus_cmd_hello *hello;
+ struct kdbus_cmd_hello *cmd;
struct kdbus_item *item;
gchar *conn_name;
size = KDBUS_ALIGN8 (G_STRUCT_OFFSET (struct kdbus_cmd_hello, items)) +
KDBUS_ALIGN8 (G_STRUCT_OFFSET (struct kdbus_item, str) + conn_name_size + 1);
- hello = g_alloca0 (size);
- hello->flags = worker->flags;
- hello->attach_flags_send = worker->attach_flags_send;
- hello->attach_flags_recv = worker->attach_flags_recv;
- hello->size = size;
- hello->pool_size = KDBUS_POOL_SIZE;
+ cmd = g_alloca0 (size);
+ cmd->flags = worker->flags;
+ cmd->attach_flags_send = worker->attach_flags_send;
+ cmd->attach_flags_recv = worker->attach_flags_recv;
+ cmd->size = size;
+ cmd->pool_size = KDBUS_POOL_SIZE;
- item = hello->items;
+ item = cmd->items;
item->size = G_STRUCT_OFFSET (struct kdbus_item, str) + conn_name_size + 1;
item->type = KDBUS_ITEM_CONN_DESCRIPTION;
memcpy (item->str, conn_name, conn_name_size+1);
item = KDBUS_ITEM_NEXT (item);
- if (ioctl(worker->fd, KDBUS_CMD_HELLO, hello))
+ if (ioctl(worker->fd, KDBUS_CMD_HELLO, cmd))
{
g_set_error (error, G_IO_ERROR,
g_io_error_from_errno (errno),
return NULL;
}
- if (hello->bus_flags > 0xFFFFFFFFULL)
+ if (cmd->bus_flags > 0xFFFFFFFFULL)
{
g_set_error_literal (error,
G_IO_ERROR,
return NULL;
}
- memcpy (worker->bus_id, hello->id128, 16);
+ memcpy (worker->bus_id, cmd->id128, 16);
- worker->unique_id = hello->id;
- asprintf(&worker->unique_name, ":1.%llu", (unsigned long long) hello->id);
+ worker->unique_id = cmd->id;
+ asprintf(&worker->unique_name, ":1.%llu", (unsigned long long) cmd->id);
/* read bloom filters parameters */
- //worker->bloom_size = (gsize) hello->bloom.size;
- //worker->bloom_n_hash = (guint) hello->bloom.n_hash;
+ //worker->bloom_size = (gsize) cmd->bloom.size;
+ //worker->bloom_n_hash = (guint) cmd->bloom.n_hash;
return g_variant_new ("(s)", worker->unique_name);
}
GError **error)
{
GVariant *result;
- struct kdbus_cmd *kdbus_name;
+ struct kdbus_cmd *cmd;
guint64 kdbus_flags;
gssize len, size;
gint status, ret;
len = strlen(name) + 1;
size = G_STRUCT_OFFSET (struct kdbus_cmd, items) + KDBUS_ITEM_SIZE(len);
- kdbus_name = g_alloca0 (size);
- kdbus_name->size = size;
- kdbus_name->items[0].size = KDBUS_ITEM_HEADER_SIZE + len;
- kdbus_name->items[0].type = KDBUS_ITEM_NAME;
- kdbus_name->flags = kdbus_flags;
- memcpy (kdbus_name->items[0].str, name, len);
-
- ret = ioctl(worker->fd, KDBUS_CMD_NAME_ACQUIRE, kdbus_name);
+ cmd = g_alloca0 (size);
+ cmd->size = size;
+ cmd->items[0].size = KDBUS_ITEM_HEADER_SIZE + len;
+ cmd->items[0].type = KDBUS_ITEM_NAME;
+ cmd->flags = kdbus_flags;
+ memcpy (cmd->items[0].str, name, len);
+
+ ret = ioctl(worker->fd, KDBUS_CMD_NAME_ACQUIRE, cmd);
if (ret < 0)
{
if (errno == EEXIST)
}
}
- if (kdbus_name->flags & KDBUS_NAME_IN_QUEUE)
+ if (cmd->flags & KDBUS_NAME_IN_QUEUE)
status = G_BUS_REQUEST_NAME_FLAGS_IN_QUEUE;
result = g_variant_new ("(u)", status);
GError **error)
{
GVariant *result;
- struct kdbus_cmd *kdbus_name;
+ struct kdbus_cmd *cmd;
gssize len, size;
gint status, ret;
len = strlen(name) + 1;
size = G_STRUCT_OFFSET (struct kdbus_cmd, items) + KDBUS_ITEM_SIZE(len);
- kdbus_name = g_alloca0 (size);
- kdbus_name->size = size;
- kdbus_name->items[0].size = KDBUS_ITEM_HEADER_SIZE + len;
- kdbus_name->items[0].type = KDBUS_ITEM_NAME;
- memcpy (kdbus_name->items[0].str, name, len);
+ cmd = g_alloca0 (size);
+ cmd->size = size;
+ cmd->items[0].size = KDBUS_ITEM_HEADER_SIZE + len;
+ cmd->items[0].type = KDBUS_ITEM_NAME;
+ memcpy (cmd->items[0].str, name, len);
- ret = ioctl(worker->fd, KDBUS_CMD_NAME_RELEASE, kdbus_name);
+ ret = ioctl(worker->fd, KDBUS_CMD_NAME_RELEASE, cmd);
if (ret < 0)
{
if (errno == ESRCH)
{
GVariant *result;
GVariantBuilder *builder;
-
- struct kdbus_cmd_list cmd = {};
struct kdbus_info *name_list, *name;
+ struct kdbus_cmd_list cmd = {
+ .size = sizeof(cmd)
+ };
guint64 prev_id;
gint ret;
else
cmd.flags = KDBUS_LIST_UNIQUE | KDBUS_LIST_NAMES; /* ListNames */
- cmd.size = sizeof(cmd);
ret = ioctl(worker->fd, KDBUS_CMD_LIST, &cmd);
if (ret < 0)
{
GString *unique_name;
gint ret;
- struct kdbus_cmd_list cmd = {};
struct kdbus_info *name_list, *kname;
+ struct kdbus_cmd_list cmd = {
+ .size = sizeof(cmd),
+ .flags = KDBUS_LIST_QUEUED
+ };
if (!g_dbus_is_name (name))
{
return NULL;
}
- cmd.flags = KDBUS_LIST_QUEUED;
- cmd.size = sizeof(cmd);
ret = ioctl(worker->fd, KDBUS_CMD_LIST, &cmd);
if (ret < 0)
{
MatchElement *element;
const gchar *sender_name;
gsize sender_len, size;
- struct kdbus_cmd_match *cmd_match;
+ struct kdbus_cmd_match *cmd;
struct kdbus_item *item;
guint64 *bloom;
guint64 src_id;
}
size += KDBUS_ALIGN8 (G_STRUCT_OFFSET (struct kdbus_item, data64) + worker->bloom_size);
- cmd_match = g_alloca0 (size);
- cmd_match->size = size;
- cmd_match->cookie = cookie;
+ cmd = g_alloca0 (size);
+ cmd->size = size;
+ cmd->cookie = cookie;
- item = cmd_match->items;
+ item = cmd->items;
item->size = G_STRUCT_OFFSET(struct kdbus_item, data64) + worker->bloom_size;
item->type = KDBUS_ITEM_BLOOM_MASK;
memcpy(item->data64, bloom, worker->bloom_size);
memcpy (item->str, sender_name, sender_len);
}
- ret = ioctl(worker->fd, KDBUS_CMD_MATCH_ADD, cmd_match);
+ ret = ioctl(worker->fd, KDBUS_CMD_MATCH_ADD, cmd);
if (ret < 0)
g_critical ("Error while adding a match: %d", cookie);
_g_kdbus_RemoveMatch (GKDBusWorker *worker,
guint cookie)
{
- struct kdbus_cmd_match cmd_match = {};
+ struct kdbus_cmd_match cmd = {
+ .size = sizeof(cmd),
+ .cookie = cookie
+ };
gint ret;
- cmd_match.size = sizeof (cmd_match);
- cmd_match.cookie = cookie;
-
- ret = ioctl(worker->fd, KDBUS_CMD_MATCH_REMOVE, &cmd_match);
+ ret = ioctl(worker->fd, KDBUS_CMD_MATCH_REMOVE, &cmd);
if (ret < 0)
g_warning ("Error while removing a match: %d\n", (int) errno);
}
guint cookie)
{
struct kdbus_item *item;
- struct kdbus_cmd_match *cmd_match;
+ struct kdbus_cmd_match *cmd;
gssize size, len;
gint ret;
guint64 old_id = 0; /* XXX why? */
G_STRUCT_OFFSET (struct kdbus_item, name_change) +
G_STRUCT_OFFSET (struct kdbus_notify_name_change, name) + len);
- cmd_match = g_alloca0 (size);
- cmd_match->size = size;
- cmd_match->cookie = cookie;
- item = cmd_match->items;
+ cmd = g_alloca0 (size);
+ cmd->size = size;
+ cmd->cookie = cookie;
+ item = cmd->items;
if (old_name[0] == 0)
{
return;
}
- cmd_match = g_alloca0 (size);
- cmd_match->size = size;
- cmd_match->cookie = cookie;
- item = cmd_match->items;
+ cmd = g_alloca0 (size);
+ cmd->size = size;
+ cmd->cookie = cookie;
+ item = cmd->items;
/* KDBUS_ITEM_NAME_CHANGE */
item->type = KDBUS_ITEM_NAME_CHANGE;
G_STRUCT_OFFSET(struct kdbus_notify_name_change, name) + len;
item = KDBUS_ITEM_NEXT(item);
- ret = ioctl(worker->fd, KDBUS_CMD_MATCH_ADD, cmd_match);
+ ret = ioctl(worker->fd, KDBUS_CMD_MATCH_ADD, cmd);
if (ret < 0)
g_warning ("ERROR - %d\n", (int) errno);
}
const gchar *name)
{
struct kdbus_item *item;
- struct kdbus_cmd_match *cmd_match;
+ struct kdbus_cmd_match *cmd;
gssize size, len;
guint64 cookie;
gint ret;
G_STRUCT_OFFSET (struct kdbus_notify_name_change, name) + len);
cookie = 0xbeefbeefbeefbeef;
- cmd_match = g_alloca0 (size);
- cmd_match->size = size;
- cmd_match->cookie = cookie;
- item = cmd_match->items;
+ cmd = g_alloca0 (size);
+ cmd->size = size;
+ cmd->cookie = cookie;
+ item = cmd->items;
/* KDBUS_ITEM_NAME_ADD */
item->type = KDBUS_ITEM_NAME_ADD;
G_STRUCT_OFFSET(struct kdbus_notify_name_change, name) + len;
item = KDBUS_ITEM_NEXT(item);
- ret = ioctl(worker->fd, KDBUS_CMD_MATCH_ADD, cmd_match);
+ ret = ioctl(worker->fd, KDBUS_CMD_MATCH_ADD, cmd);
if (ret < 0)
g_warning ("ERROR - %d\n", (int) errno);
const gchar *name)
{
struct kdbus_item *item;
- struct kdbus_cmd_match *cmd_match;
+ struct kdbus_cmd_match *cmd;
gssize size, len;
guint64 cookie;
gint ret;
G_STRUCT_OFFSET (struct kdbus_notify_name_change, name) + len);
cookie = 0xdeafdeafdeafdeaf;
- cmd_match = g_alloca0 (size);
- cmd_match->size = size;
- cmd_match->cookie = cookie;
- item = cmd_match->items;
+ cmd = g_alloca0 (size);
+ cmd->size = size;
+ cmd->cookie = cookie;
+ item = cmd->items;
/* KDBUS_ITEM_NAME_REMOVE */
item->type = KDBUS_ITEM_NAME_REMOVE;
G_STRUCT_OFFSET(struct kdbus_notify_name_change, name) + len;
item = KDBUS_ITEM_NEXT(item);
- ret = ioctl(worker->fd, KDBUS_CMD_MATCH_ADD, cmd_match);
+ ret = ioctl(worker->fd, KDBUS_CMD_MATCH_ADD, cmd);
if (ret < 0)
g_warning ("ERROR - %d\n", (int) errno);