
On a Monday in 2020, Ryan Gahagan wrote:
From: Barrett Schonefeld <bschoney@utexas.edu>
- src/util/virvhba.c
Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu> --- src/util/virvhba.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/src/util/virvhba.c b/src/util/virvhba.c index a80145b8fd..e0a79344cc 100644 --- a/src/util/virvhba.c +++ b/src/util/virvhba.c @@ -121,10 +121,10 @@ virVHBAGetConfig(const char *sysfs_prefix, sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH, host, entry);
if (!virFileExists(sysfs_path)) - goto cleanup; + return result;
At this point, result is NULL so you can return it directly.
if (virFileReadAll(sysfs_path, 1024, &buf) < 0) - goto cleanup; + return result;
Same here.
if ((p = strchr(buf, '\n'))) *p = '\0'; @@ -136,7 +136,6 @@ virVHBAGetConfig(const char *sysfs_prefix,
result = g_strdup(p);
- cleanup: return result;
and just return g_strdup(p); here to avoid the need for 'result' completely.
}
@@ -206,15 +205,13 @@ virVHBAFindVportHost(const char *sysfs_prefix) if ((strlen(max_vports) >= strlen(vports)) || ((strlen(max_vports) == strlen(vports)) && strcmp(max_vports, vports) > 0)) { - ret = g_strdup(entry->d_name); - goto cleanup; + return g_strdup(entry->d_name); }
VIR_FREE(max_vports); VIR_FREE(vports); }
- cleanup: return ret; }
return NULL;
@@ -248,7 +245,7 @@ virVHBAManageVport(const int parent_host, default: virReportError(VIR_ERR_OPERATION_INVALID, _("Invalid vport operation (%d)"), operation); - goto cleanup; + return ret;
return -1;
}
operation_path = g_strdup_printf("%s/host%d/%s", SYSFS_FC_HOST_PATH, @@ -264,7 +261,7 @@ virVHBAManageVport(const int parent_host, _("vport operation '%s' is not supported " "for host%d"), operation_file, parent_host); - goto cleanup; + return ret;
return -1;
} }
@@ -284,7 +281,6 @@ virVHBAManageVport(const int parent_host, "vport create/delete failed"), vport_name, operation_path);
- cleanup: return ret; }
@@ -315,12 +311,11 @@ vhbaReadCompareWWN(const char *prefix, path = g_strdup_printf("%s/%s/%s", prefix, d_name, f_name);
if (!virFileExists(path)) { - ret = 0; - goto cleanup; + return 0; }
if (virFileReadAll(path, 1024, &buf) < 0) - goto cleanup; + return ret;
return -1;
if ((p = strchr(buf, '\n'))) *p = '\0'; @@ -334,8 +329,6 @@ vhbaReadCompareWWN(const char *prefix, else ret = 1;
- cleanup: - return ret; }
@@ -418,7 +411,7 @@ virVHBAGetHostByFabricWWN(const char *sysfs_prefix,
if ((rc = vhbaReadCompareWWN(prefix, entry->d_name, "fabric_name", fabric_wwn)) < 0) - goto cleanup; + return ret;
return NULL; Jano