On 06/07/2013 04:06 PM, Michal Privoznik wrote:
There's no sense in using virAsprintf() just to duplicate a
string.
We should use VIR_STRDUP which is designed just for that.
---
daemon/libvirtd-config.c | 2 +-
src/conf/domain_audit.c | 2 +-
src/libxl/libxl_driver.c | 30 ++++++++++++------------------
src/nwfilter/nwfilter_ebiptables_driver.c | 2 +-
src/phyp/phyp_driver.c | 4 +---
src/storage/storage_backend_scsi.c | 4 +---
6 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 70d3adb..2df082b 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -259,10 +259,8 @@ phypGetSystemType(virConnectPtr conn)
char *ret = NULL;
int exit_status = 0;
- if (virAsprintf(&cmd, "lshmc -V") < 0) {
- virReportOOMError();
+ if (VIR_STRDUP(cmd, "lshmc -V") < 0)
return -1;
- }
ret = phypExec(session, cmd, &exit_status, conn);
ret = phypExec(session, "lshmc -V", &exit_status, conn);
VIR_FREE(cmd);
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index bd6a2a9..4dad1eb 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -507,10 +507,8 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
virFileWaitForDevices();
- if (virAsprintf(&device_path, "/sys/bus/scsi/devices") < 0) {
- virReportOOMError();
+ if (VIR_STRDUP(device_path, "/sys/bus/scsi/devices") < 0)
goto out;
- }
devicedir = opendir(device_path);
const char *device_path = "/sys/bus/scsi/devices";
would make this much simpler.
ACK either way
Jan