提交 add80dbe 编写于 作者: S Sukrit Bhatnagar 提交者: Erik Skultety

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: NSukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 12614e7e
...@@ -111,8 +111,7 @@ virAuthGetCredential(const char *servicename, ...@@ -111,8 +111,7 @@ virAuthGetCredential(const char *servicename,
const char *path, const char *path,
char **value) char **value)
{ {
int ret = -1; VIR_AUTOPTR(virAuthConfig) config = NULL;
virAuthConfigPtr config = NULL;
const char *tmp; const char *tmp;
*value = NULL; *value = NULL;
...@@ -121,23 +120,19 @@ virAuthGetCredential(const char *servicename, ...@@ -121,23 +120,19 @@ virAuthGetCredential(const char *servicename,
return 0; return 0;
if (!(config = virAuthConfigNew(path))) if (!(config = virAuthConfigNew(path)))
goto cleanup; return -1;
if (virAuthConfigLookup(config, if (virAuthConfigLookup(config,
servicename, servicename,
hostname, hostname,
credname, credname,
&tmp) < 0) &tmp) < 0)
goto cleanup; return -1;
if (VIR_STRDUP(*value, tmp) < 0) if (VIR_STRDUP(*value, tmp) < 0)
goto cleanup; return -1;
ret = 0;
cleanup: return 0;
virAuthConfigFree(config);
return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册