提交 1d0fde7e 编写于 作者: J John Ferlan

util: Remove need for extra VIR_FREE's in virGetFCHostNameByWWN

Rather than extraneous VIR_FREE's depending on where we are in the code,
move them to the top of the loop and in the cleanup path.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 9fdc8c42
...@@ -2205,43 +2205,34 @@ virGetFCHostNameByWWN(const char *sysfs_prefix, ...@@ -2205,43 +2205,34 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
} while (0) } while (0)
while (virDirRead(dir, &entry, prefix) > 0) { while (virDirRead(dir, &entry, prefix) > 0) {
VIR_FREE(wwnn_buf);
VIR_FREE(wwnn_path);
VIR_FREE(wwpn_buf);
VIR_FREE(wwpn_path);
if (virAsprintf(&wwnn_path, "%s/%s/node_name", prefix, if (virAsprintf(&wwnn_path, "%s/%s/node_name", prefix,
entry->d_name) < 0) entry->d_name) < 0)
goto cleanup; goto cleanup;
if (!virFileExists(wwnn_path)) { if (!virFileExists(wwnn_path))
VIR_FREE(wwnn_path);
continue; continue;
}
READ_WWN(wwnn_path, wwnn_buf); READ_WWN(wwnn_path, wwnn_buf);
if (STRNEQ(wwnn, p)) { if (STRNEQ(wwnn, p))
VIR_FREE(wwnn_buf);
VIR_FREE(wwnn_path);
continue; continue;
}
if (virAsprintf(&wwpn_path, "%s/%s/port_name", prefix, if (virAsprintf(&wwpn_path, "%s/%s/port_name", prefix,
entry->d_name) < 0) entry->d_name) < 0)
goto cleanup; goto cleanup;
if (!virFileExists(wwpn_path)) { if (!virFileExists(wwpn_path))
VIR_FREE(wwnn_buf);
VIR_FREE(wwnn_path);
VIR_FREE(wwpn_path);
continue; continue;
}
READ_WWN(wwpn_path, wwpn_buf); READ_WWN(wwpn_path, wwpn_buf);
if (STRNEQ(wwpn, p)) { if (STRNEQ(wwpn, p))
VIR_FREE(wwnn_path);
VIR_FREE(wwpn_path);
VIR_FREE(wwnn_buf);
VIR_FREE(wwpn_buf);
continue; continue;
}
ignore_value(VIR_STRDUP(ret, entry->d_name)); ignore_value(VIR_STRDUP(ret, entry->d_name));
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册