unit_choose_id() is about marking one of the aliases of the unit as the main
name. With the preparatory work in previous patches, all aliases of the unit
must have the same instance, so the operation to update the instance is a noop.
}
int unit_choose_id(Unit *u, const char *name) {
- _cleanup_free_ char *t = NULL, *i = NULL;
+ _cleanup_free_ char *t = NULL;
char *s;
int r;
if (!s)
return -ENOENT;
- /* Determine the new instance from the new id */
- r = unit_name_to_instance(name, &i);
- if (r < 0)
- return r;
-
if (u->id) {
r = set_remove_and_put(u->aliases, name, u->id);
if (r < 0)
assert_se(set_remove(u->aliases, name)); /* see set_get() above… */
u->id = s; /* Old u->id is now stored in the set, and s is not stored anywhere */
-
- free(u->instance);
- u->instance = i;
-
unit_add_to_dbus_queue(u);
return 0;