KDBUS_ITEMS_FOREACH(item, cmd->items, KDBUS_ITEMS_SIZE(cmd, items)) {
switch (item->type) {
case KDBUS_ITEM_ATTACH_FLAGS:
- /* Only ordinary or monitor connections
- * may update their attach-flags */
+ /*
+ * Only ordinary or monitor connections
+ * may update their attach-flags.
+ */
if (!kdbus_conn_is_connected(conn) &&
!kdbus_conn_is_monitor(conn))
return -EOPNOTSUPP;
case KDBUS_ITEM_NAME:
case KDBUS_ITEM_POLICY_ACCESS:
- /* Only policy holders may update their policy
- * entries */
+ /*
+ * Only policy holders may update their policy entries.
+ */
if (!kdbus_conn_is_policy_holder(conn))
return -EOPNOTSUPP;
if (WARN_ON(p & 0x3UL || type >= KDBUS_MINOR_CNT))
return NULL;
- return (void*)(p | (unsigned long)type);
+ return (void *)(p | (unsigned long)type);
}
static enum kdbus_minor_type kdbus_minor_unpack(void **ptr)
{
unsigned long p = (unsigned long)*ptr;
- *ptr = (void*)(p & ~0x3UL);
+ *ptr = (void *)(p & ~0x3UL);
return p & 0x3UL;
}
int seals, mask;
int fd = item->memfd.fd;
- /*
- * Verify the fd and increment the usage
- * count
- */
- if (fd < 0 || !(f = fget(fd)))
+ /* Verify the fd and increment the usage count */
+ if (fd < 0)
+ return -EBADF;
+
+ f = fget(fd);
+ if (!f)
return -EBADF;
kmsg->memfds[kmsg->memfds_count] = f;
int fd = item->fds[i];
/*
- * Verify the fd and increment the
- * usage count. Use fget_raw() to allow
- * passing O_PATH fds
+ * Verify the fd and increment the usage count.
+ * Use fget_raw() to allow passing O_PATH fds.
*/
- if (fd < 0 || !(f = fget_raw(fd)))
+ if (fd < 0)
+ return -EBADF;
+
+ f = fget_raw(fd);
+ if (!f)
return -EBADF;
kmsg->fds[i] = f;