mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
util: fcp: use VIR_AUTOFREE instead of VIR_FREE for scalar types
By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls 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
b204fbc47e
commit
10f888e64e
@ -40,16 +40,12 @@
|
|||||||
bool
|
bool
|
||||||
virFCIsCapableRport(const char *rport)
|
virFCIsCapableRport(const char *rport)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
VIR_AUTOFREE(char *) path = NULL;
|
||||||
char *path = NULL;
|
|
||||||
|
|
||||||
if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0)
|
if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ret = virFileExists(path);
|
return virFileExists(path);
|
||||||
VIR_FREE(path);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -57,8 +53,8 @@ virFCReadRportValue(const char *rport,
|
|||||||
const char *entry,
|
const char *entry,
|
||||||
char **result)
|
char **result)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
VIR_AUTOFREE(char *) buf = NULL;
|
||||||
char *buf = NULL, *p = NULL;
|
char *p = NULL;
|
||||||
|
|
||||||
if (virFileReadValueString(&buf, "%s/%s/%s",
|
if (virFileReadValueString(&buf, "%s/%s/%s",
|
||||||
SYSFS_FC_RPORT_PATH, rport, entry) < 0) {
|
SYSFS_FC_RPORT_PATH, rport, entry) < 0) {
|
||||||
@ -69,13 +65,9 @@ virFCReadRportValue(const char *rport,
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
if (VIR_STRDUP(*result, buf) < 0)
|
if (VIR_STRDUP(*result, buf) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(buf);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user