提交 f72393fa 编写于 作者: E Eric Blake

storage: use virCommand to avoid compiler warning

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.
上级 ead2b433
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "memory.h" #include "memory.h"
#include "logging.h" #include "logging.h"
#include "files.h" #include "files.h"
#include "command.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE #define VIR_FROM_THIS VIR_FROM_STORAGE
...@@ -348,28 +349,11 @@ virStorageBackendISCSIConnection(const char *portal, ...@@ -348,28 +349,11 @@ virStorageBackendISCSIConnection(const char *portal,
"--targetname", target, "--targetname", target,
NULL NULL
}; };
int i; virCommandPtr cmd;
int nargs = 0;
char *ifacename = NULL; 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; cmd = virCommandNewArgs(baseargv);
for (i = 0 ; baseargv[i] != NULL ; i++) virCommandAddArgSet(cmd, extraargv);
cmdargv[nargs++] = baseargv[i];
for (i = 0 ; extraargv[i] != NULL ; i++)
cmdargv[nargs++] = extraargv[i];
if (initiatoriqn) { if (initiatoriqn) {
switch (virStorageBackendIQNFound(initiatoriqn, &ifacename)) { switch (virStorageBackendIQNFound(initiatoriqn, &ifacename)) {
...@@ -377,7 +361,8 @@ virStorageBackendISCSIConnection(const char *portal, ...@@ -377,7 +361,8 @@ virStorageBackendISCSIConnection(const char *portal,
VIR_DEBUG("ifacename: '%s'", ifacename); VIR_DEBUG("ifacename: '%s'", ifacename);
break; break;
case IQN_MISSING: case IQN_MISSING:
if (virStorageBackendCreateIfaceIQN(initiatoriqn, &ifacename) != 0) { if (virStorageBackendCreateIfaceIQN(initiatoriqn,
&ifacename) != 0) {
goto cleanup; goto cleanup;
} }
break; break;
...@@ -385,19 +370,16 @@ virStorageBackendISCSIConnection(const char *portal, ...@@ -385,19 +370,16 @@ virStorageBackendISCSIConnection(const char *portal,
default: default:
goto cleanup; goto cleanup;
} }
virCommandAddArgList(cmd, "--interface", ifacename, NULL);
cmdargv[nargs++] = "--interface";
cmdargv[nargs++] = ifacename;
} }
cmdargv[nargs++] = NULL;
if (virRun(cmdargv, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(cmdargv); virCommandFree(cmd);
VIR_FREE(ifacename); VIR_FREE(ifacename);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册