mirror of https://gitee.com/openkylin/libvirt.git
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.
This commit is contained in:
parent
ead2b43357
commit
f72393fa97
|
@ -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,
|
||||||
"--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++)
|
cmd = virCommandNewArgs(baseargv);
|
||||||
nargs++;
|
virCommandAddArgSet(cmd, extraargv);
|
||||||
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];
|
|
||||||
|
|
||||||
if (initiatoriqn) {
|
if (initiatoriqn) {
|
||||||
switch (virStorageBackendIQNFound(initiatoriqn, &ifacename)) {
|
switch (virStorageBackendIQNFound(initiatoriqn, &ifacename)) {
|
||||||
|
@ -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,
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue