By making use of the GCC's __attribute__((cleanup)) handled by VIR_AUTOPTR
macro, majority of the calls to *Free functions can be dropped, which in
turn leads to getting rid of most of our cleanup sections.
---
src/util/virauth.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/util/virauth.c b/src/util/virauth.c
index d3a5cc7..f000d45 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -111,8 +111,7 @@ virAuthGetCredential(const char *servicename,
const char *path,
char **value)
{
- int ret = -1;
- virAuthConfigPtr config = NULL;
+ VIR_AUTOPTR(virAuthConfigPtr) 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;
-
- ret = 0;
+ return -1;
- cleanup:
- virAuthConfigFree(config);
- return ret;
+ return 0;
}
--
1.8.3.1