KDBUS_ITEM_NAME_{ADD,REMOVE,CHANGE} embed their string in
item->name_change.name, not item->str. Handle that case.
Signed-off-by: Daniel Mack <daniel@zonque.org>
*
* This function walks a list of items and searches for items of type
* @item_type. If it finds exactly one such item, @str_ret will be set to
- * the .str member of the item.
+ * the string member of the item.
*
* Return: 0 if the item was found exactly once, -EEXIST if the item was
* found more than once, and -EBADMSG if there was no item of the given type.
if (n)
return -EEXIST;
- n = item->str;
- continue;
+ switch (item_type) {
+ case KDBUS_ITEM_NAME_ADD:
+ case KDBUS_ITEM_NAME_REMOVE:
+ case KDBUS_ITEM_NAME_CHANGE:
+ n = (const char *) &item->name_change.name;
+ break;
+
+ case KDBUS_ITEM_NAME:
+ case KDBUS_ITEM_MAKE_NAME:
+ n = item->str;
+ break;
+
+ default:
+ break;
+ }
}
}