clang didn't like the last increment to nargs. But why even
track nargs ourselves, when virCommand does it for us?
* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSIConnection): Switch to virCommand to avoid
a dead-store warning on nargs.
---
src/storage/storage_backend_iscsi.c | 36 ++++++++--------------------------
1 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index d86f077..ec52dbc 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -42,6 +42,7 @@
#include "memory.h"
#include "logging.h"
#include "files.h"
+#include "command.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE
@@ -348,28 +349,11 @@ virStorageBackendISCSIConnection(const char *portal,
"--targetname", target,
NULL
};
- int i;
- int nargs = 0;
+ virCommandPtr cmd;
char *ifacename = NULL;
- const char **cmdargv;
-
- for (i = 0 ; baseargv[i] != NULL ; i++)
- nargs++;
- for (i = 0 ; extraargv[i] != NULL ; i++)
- nargs++;
- if (initiatoriqn)
- nargs += 2;
-
- if (VIR_ALLOC_N(cmdargv, nargs+1) < 0) {
- virReportOOMError();
- return -1;
- }
- nargs = 0;
- for (i = 0 ; baseargv[i] != NULL ; i++)
- cmdargv[nargs++] = baseargv[i];
- for (i = 0 ; extraargv[i] != NULL ; i++)
- cmdargv[nargs++] = extraargv[i];
+ cmd = virCommandNewArgs(baseargv);
+ virCommandAddArgSet(cmd, extraargv);
if (initiatoriqn) {
switch (virStorageBackendIQNFound(initiatoriqn, &ifacename)) {
@@ -377,7 +361,8 @@ virStorageBackendISCSIConnection(const char *portal,
VIR_DEBUG("ifacename: '%s'", ifacename);
break;
case IQN_MISSING:
- if (virStorageBackendCreateIfaceIQN(initiatoriqn, &ifacename) != 0) {
+ if (virStorageBackendCreateIfaceIQN(initiatoriqn,
+ &ifacename) != 0) {
goto cleanup;
}
break;
@@ -385,19 +370,16 @@ virStorageBackendISCSIConnection(const char *portal,
default:
goto cleanup;
}
-
- cmdargv[nargs++] = "--interface";
- cmdargv[nargs++] = ifacename;
+ virCommandAddArgList(cmd, "--interface", ifacename, NULL);
}
- cmdargv[nargs++] = NULL;
- if (virRun(cmdargv, NULL) < 0)
+ if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
ret = 0;
cleanup:
- VIR_FREE(cmdargv);
+ virCommandFree(cmd);
VIR_FREE(ifacename);
return ret;
--
1.7.4.4
Show replies by date
On 05/03/2011 06:14 PM, Eric Blake wrote:
clang didn't like the last increment to nargs. But why even
track nargs ourselves, when virCommand does it for us?
* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSIConnection): Switch to virCommand to avoid
a dead-store warning on nargs.
---
src/storage/storage_backend_iscsi.c | 36 ++++++++--------------------------
1 files changed, 9 insertions(+), 27 deletions(-)
ACK. It really is nice how much cruft is removed when switching to
virCommand!
On 05/03/2011 10:32 PM, Laine Stump wrote:
On 05/03/2011 06:14 PM, Eric Blake wrote:
> clang didn't like the last increment to nargs. But why even
> track nargs ourselves, when virCommand does it for us?
>
> * src/storage/storage_backend_iscsi.c
> (virStorageBackendISCSIConnection): Switch to virCommand to avoid
> a dead-store warning on nargs.
> ---
> src/storage/storage_backend_iscsi.c | 36
> ++++++++--------------------------
> 1 files changed, 9 insertions(+), 27 deletions(-)
ACK. It really is nice how much cruft is removed when switching to
virCommand!
Thanks; pushed.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org