提交 27950465 编写于 作者: J John Ferlan

secret: Introduce listUnlinkSecret

Add a temporary helper to search for a specific secret by address
on the list and remove it if it's found. The following patch will
introduce a common allocation and listInsert helper. That means
error paths of the routines calling would need a way to remove the
secret off the list.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 0250f34a
......@@ -353,6 +353,26 @@ secretLoadValue(virSecretObjPtr secret)
return ret;
}
static void
listUnlinkSecret(virSecretObjPtr *pptr,
virSecretObjPtr secret)
{
if (!secret)
return;
if (*pptr == secret) {
*pptr = secret->next;
} else {
virSecretObjPtr tmp = *pptr;
while (tmp && tmp->next != secret)
tmp = tmp->next;
if (tmp)
tmp->next = secret->next;
}
}
static virSecretObjPtr
secretLoad(const char *file,
const char *path,
......@@ -980,15 +1000,7 @@ secretUndefine(virSecretPtr obj)
secretDeleteSaved(secret) < 0)
goto cleanup;
if (driver->secrets == secret) {
driver->secrets = secret->next;
} else {
virSecretObjPtr tmp = driver->secrets;
while (tmp && tmp->next != secret)
tmp = tmp->next;
if (tmp)
tmp->next = secret->next;
}
listUnlinkSecret(&driver->secrets, secret);
secretFree(secret);
ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册