mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
util: auth: use VIR_AUTOPTR for aggregate types
By making use of GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
12614e7e25
commit
add80dbe7e
@ -111,8 +111,7 @@ virAuthGetCredential(const char *servicename,
|
||||
const char *path,
|
||||
char **value)
|
||||
{
|
||||
int ret = -1;
|
||||
virAuthConfigPtr config = NULL;
|
||||
VIR_AUTOPTR(virAuthConfig) config = NULL;
|
||||
const char *tmp;
|
||||
|
||||
*value = NULL;
|
||||
@ -121,23 +120,19 @@ virAuthGetCredential(const char *servicename,
|
||||
return 0;
|
||||
|
||||
if (!(config = virAuthConfigNew(path)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virAuthConfigLookup(config,
|
||||
servicename,
|
||||
hostname,
|
||||
credname,
|
||||
&tmp) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (VIR_STRDUP(*value, tmp) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virAuthConfigFree(config);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user