mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
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: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
0250f34af1
commit
27950465b1
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user