提交 a39875b7 编写于 作者: M Michal Privoznik

Adapt to VIR_STRDUP and VIR_STRNDUP in src/phyp/*

上级 b3c649ac
...@@ -954,12 +954,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, ...@@ -954,12 +954,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
} }
if (conn->uri->user != NULL) { if (conn->uri->user != NULL) {
username = strdup(conn->uri->user); if (VIR_STRDUP(username, conn->uri->user) < 0)
if (username == NULL) {
virReportOOMError();
goto err; goto err;
}
} else { } else {
if (auth == NULL || auth->cb == NULL) { if (auth == NULL || auth->cb == NULL) {
virReportError(VIR_ERR_AUTH_FAILED, virReportError(VIR_ERR_AUTH_FAILED,
...@@ -1141,15 +1137,9 @@ phypConnectOpen(virConnectPtr conn, ...@@ -1141,15 +1137,9 @@ phypConnectOpen(virConnectPtr conn,
if (conn->uri->path) { if (conn->uri->path) {
/* need to shift one byte in order to remove the first "/" of URI component */ /* need to shift one byte in order to remove the first "/" of URI component */
if (conn->uri->path[0] == '/') if (VIR_STRDUP(managed_system,
managed_system = strdup(conn->uri->path + 1); conn->uri->path + (conn->uri->path[0] == '/')) < 0)
else
managed_system = strdup(conn->uri->path);
if (!managed_system) {
virReportOOMError();
goto failure; goto failure;
}
/* here we are handling only the first component of the path, /* here we are handling only the first component of the path,
* so skipping the second: * so skipping the second:
...@@ -1498,12 +1488,8 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system, ...@@ -1498,12 +1488,8 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
else else
goto cleanup; goto cleanup;
backing_device = strdup(char_ptr); if (VIR_STRDUP(backing_device, char_ptr) < 0)
if (backing_device == NULL) {
virReportOOMError();
goto cleanup; goto cleanup;
}
} else { } else {
backing_device = ret; backing_device = ret;
ret = NULL; ret = NULL;
...@@ -1731,12 +1717,8 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml) ...@@ -1731,12 +1717,8 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml)
goto cleanup; goto cleanup;
} }
def->os.type = strdup("aix"); if (VIR_STRDUP(def->os.type, "aix") < 0)
if (def->os.type == NULL) {
virReportOOMError();
goto cleanup; goto cleanup;
}
dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL, dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL,
VIR_DOMAIN_XML_INACTIVE); VIR_DOMAIN_XML_INACTIVE);
...@@ -2281,12 +2263,8 @@ phypStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) ...@@ -2281,12 +2263,8 @@ phypStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
goto cleanup; goto cleanup;
} }
voldef.key = strdup(vol->key); if (VIR_STRDUP(voldef.key, vol->key) < 0)
if (voldef.key == NULL) {
virReportOOMError();
goto cleanup; goto cleanup;
}
voldef.type = VIR_STORAGE_POOL_LOGICAL; voldef.type = VIR_STORAGE_POOL_LOGICAL;
...@@ -2399,10 +2377,8 @@ phypStoragePoolListVolumes(virStoragePoolPtr pool, char **const volumes, ...@@ -2399,10 +2377,8 @@ phypStoragePoolListVolumes(virStoragePoolPtr pool, char **const volumes,
if (char_ptr) { if (char_ptr) {
*char_ptr = '\0'; *char_ptr = '\0';
if ((volumes[got++] = strdup(volumes_list)) == NULL) { if (VIR_STRDUP(volumes[got++], volumes_list) < 0)
virReportOOMError();
goto cleanup; goto cleanup;
}
char_ptr++; char_ptr++;
volumes_list = char_ptr; volumes_list = char_ptr;
} else } else
...@@ -2600,10 +2576,8 @@ phypConnectListStoragePools(virConnectPtr conn, char **const pools, int npools) ...@@ -2600,10 +2576,8 @@ phypConnectListStoragePools(virConnectPtr conn, char **const pools, int npools)
if (char_ptr) { if (char_ptr) {
*char_ptr = '\0'; *char_ptr = '\0';
if ((pools[got++] = strdup(storage_pools)) == NULL) { if (VIR_STRDUP(pools[got++], storage_pools) < 0)
virReportOOMError();
goto cleanup; goto cleanup;
}
char_ptr++; char_ptr++;
storage_pools = char_ptr; storage_pools = char_ptr;
} else } else
...@@ -3067,10 +3041,8 @@ phypConnectListInterfaces(virConnectPtr conn, char **const names, int nnames) ...@@ -3067,10 +3041,8 @@ phypConnectListInterfaces(virConnectPtr conn, char **const names, int nnames)
if (char_ptr) { if (char_ptr) {
*char_ptr = '\0'; *char_ptr = '\0';
if ((names[got++] = strdup(networks)) == NULL) { if (VIR_STRDUP(names[got++], networks) < 0)
virReportOOMError();
goto cleanup; goto cleanup;
}
char_ptr++; char_ptr++;
networks = char_ptr; networks = char_ptr;
} else { } else {
...@@ -3234,10 +3206,8 @@ phypConnectListDefinedDomains(virConnectPtr conn, char **const names, int nnames ...@@ -3234,10 +3206,8 @@ phypConnectListDefinedDomains(virConnectPtr conn, char **const names, int nnames
if (char_ptr) { if (char_ptr) {
*char_ptr = '\0'; *char_ptr = '\0';
if ((names[got++] = strdup(domains)) == NULL) { if (VIR_STRDUP(names[got++], domains) < 0)
virReportOOMError();
goto cleanup; goto cleanup;
}
char_ptr++; char_ptr++;
domains = char_ptr; domains = char_ptr;
} else } else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册