mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
lib: Don't check for retval for virCommandNew*()
The virCommand module is specifically designed so that no caller has to check for retval of individual virCommand*() APIs except for virCommandRun() where the actual error is reported. Moreover, virCommandNew*() use g_new0() to allocate memory and thus it's not really possible for those APIs to return NULL. Which is why they are even marked as ATTRIBUTE_NONNULL. But there are few places where we do check the retval which is a dead code effectively. Drop those checks. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
21ad635fc3
commit
da255ce831
@ -268,8 +268,7 @@ qemuSlirpStart(virDomainObj *vm,
|
||||
if (!(pidfile = qemuSlirpCreatePidFilename(cfg, vm->def, net->info.alias)))
|
||||
return -1;
|
||||
|
||||
if (!(cmd = virCommandNew(cfg->slirpHelperName)))
|
||||
return -1;
|
||||
cmd = virCommandNew(cfg->slirpHelperName);
|
||||
|
||||
virCommandClearCaps(cmd);
|
||||
virCommandSetPidFile(cmd, pidfile);
|
||||
|
@ -279,8 +279,6 @@ qemuTPMCreateConfigFiles(const char *swtpm_setup)
|
||||
return 0;
|
||||
|
||||
cmd = virCommandNew(swtpm_setup);
|
||||
if (!cmd)
|
||||
return -1;
|
||||
|
||||
virCommandAddArgList(cmd, "--create-config-files", "skip-if-exist", NULL);
|
||||
virCommandClearCaps(cmd);
|
||||
@ -388,8 +386,6 @@ qemuTPMEmulatorRunSetup(const char *storagepath,
|
||||
return -1;
|
||||
|
||||
cmd = virCommandNew(swtpm_setup);
|
||||
if (!cmd)
|
||||
return -1;
|
||||
|
||||
virUUIDFormat(vmuuid, uuid);
|
||||
vmid = g_strdup_printf("%s:%s", vmname, uuid);
|
||||
@ -500,8 +496,6 @@ qemuTPMEmulatorReconfigure(const char *storagepath,
|
||||
return 0;
|
||||
|
||||
cmd = virCommandNew(swtpm_setup);
|
||||
if (!cmd)
|
||||
return -1;
|
||||
|
||||
virCommandSetUID(cmd, swtpm_user);
|
||||
virCommandSetGID(cmd, swtpm_group);
|
||||
@ -592,8 +586,6 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm,
|
||||
unlink(tpm->data.emulator.source->data.nix.path);
|
||||
|
||||
cmd = virCommandNew(swtpm);
|
||||
if (!cmd)
|
||||
goto error;
|
||||
|
||||
virCommandClearCaps(cmd);
|
||||
|
||||
@ -806,8 +798,6 @@ qemuTPMEmulatorStop(const char *swtpmStateDir,
|
||||
return;
|
||||
|
||||
cmd = virCommandNew(swtpm_ioctl);
|
||||
if (!cmd)
|
||||
return;
|
||||
|
||||
virCommandAddArgList(cmd, "--unix", pathname, "-s", NULL);
|
||||
|
||||
|
@ -133,8 +133,6 @@ int qemuExtVhostUserGPUStart(virQEMUDriver *driver,
|
||||
goto error;
|
||||
|
||||
cmd = virCommandNew(video->driver->vhost_user_binary);
|
||||
if (!cmd)
|
||||
goto error;
|
||||
|
||||
virCommandClearCaps(cmd);
|
||||
virCommandSetPidFile(cmd, pidfile);
|
||||
|
@ -132,8 +132,7 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg,
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
g_auto(virBuffer) opts = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
if (!(cmd = virCommandNew(fs->binary)))
|
||||
return NULL;
|
||||
cmd = virCommandNew(fs->binary);
|
||||
|
||||
virCommandAddArgFormat(cmd, "--fd=%d", *fd);
|
||||
virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
|
||||
|
@ -252,8 +252,7 @@ virTPMGetCaps(virTPMBinaryCapsParse capsParse,
|
||||
{
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
|
||||
if (!(cmd = virCommandNew(exec)))
|
||||
return NULL;
|
||||
cmd = virCommandNew(exec);
|
||||
|
||||
if (param1)
|
||||
virCommandAddArg(cmd, param1);
|
||||
|
@ -116,8 +116,7 @@ testCompareOutputLit(const char *expectData,
|
||||
g_autoptr(virCommand) cmd = NULL;
|
||||
g_autofree char *errbuf = NULL;
|
||||
|
||||
if (!(cmd = virCommandNewArgs(argv)))
|
||||
return -1;
|
||||
cmd = virCommandNewArgs(argv);
|
||||
|
||||
virCommandAddEnvString(cmd, "LANG=C");
|
||||
virCommandSetInputBuffer(cmd, empty);
|
||||
|
Loading…
Reference in New Issue
Block a user