mirror of https://gitee.com/openkylin/libvirt.git
Replace virStreamFree with virObjectUnref
Since virStreamFree will call virObjectUnref anyway, let's just use that directly so as to avoid the possibility that we inadvertently clear out a pending error message when using the public API.
This commit is contained in:
parent
adbbff5fb7
commit
1725a468f6
4
cfg.mk
4
cfg.mk
|
@ -992,7 +992,7 @@ sc_prohibit_system_error_with_vir_err:
|
||||||
# functions. There's a corresponding exclude to allow usage within tests,
|
# functions. There's a corresponding exclude to allow usage within tests,
|
||||||
# docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h
|
# docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h
|
||||||
sc_prohibit_virXXXFree:
|
sc_prohibit_virXXXFree:
|
||||||
@prohibit='\bvir(Domain|Network|NodeDevice|StorageVol|StoragePool)Free\b' \
|
@prohibit='\bvir(Domain|Network|NodeDevice|StorageVol|StoragePool|Stream)Free\b' \
|
||||||
exclude='sc_prohibit_virXXXFree' \
|
exclude='sc_prohibit_virXXXFree' \
|
||||||
halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \
|
halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \
|
||||||
$(_sc_search_regexp)
|
$(_sc_search_regexp)
|
||||||
|
@ -1186,4 +1186,4 @@ exclude_file_name_regexp--sc_prohibit_devname = \
|
||||||
^(tools/virsh.pod|cfg.mk|docs/.*)$$
|
^(tools/virsh.pod|cfg.mk|docs/.*)$$
|
||||||
|
|
||||||
exclude_file_name_regexp--sc_prohibit_virXXXFree = \
|
exclude_file_name_regexp--sc_prohibit_virXXXFree = \
|
||||||
^(docs/|tests/|examples/|tools/|cfg.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage).h|src/libvirt-(domain|qemu|network|nodedev|storage).c$$)
|
^(docs/|tests/|examples/|tools/|cfg.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage|stream).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream).c$$)
|
||||||
|
|
|
@ -5414,7 +5414,7 @@ remoteDispatchDomainMigratePrepareTunnel3Params(virNetServerPtr server ATTRIBUTE
|
||||||
virStreamAbort(st);
|
virStreamAbort(st);
|
||||||
daemonFreeClientStream(client, stream);
|
daemonFreeClientStream(client, stream);
|
||||||
} else {
|
} else {
|
||||||
virStreamFree(st);
|
virObjectUnref(st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -383,7 +383,7 @@ int daemonFreeClientStream(virNetServerClientPtr client,
|
||||||
msg = tmp;
|
msg = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
virStreamFree(stream->st);
|
virObjectUnref(stream->st);
|
||||||
VIR_FREE(stream);
|
VIR_FREE(stream);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -221,7 +221,7 @@ static void virChrdevHashEntryFree(void *data,
|
||||||
virStreamPtr st = data;
|
virStreamPtr st = data;
|
||||||
|
|
||||||
/* free stream reference */
|
/* free stream reference */
|
||||||
virStreamFree(st);
|
virObjectUnref(st);
|
||||||
|
|
||||||
/* delete lock file */
|
/* delete lock file */
|
||||||
virChrdevLockFileRemove(dev);
|
virChrdevLockFileRemove(dev);
|
||||||
|
@ -346,7 +346,6 @@ int virChrdevOpen(virChrdevsPtr devs,
|
||||||
char *path;
|
char *path;
|
||||||
int ret;
|
int ret;
|
||||||
bool added = false;
|
bool added = false;
|
||||||
virErrorPtr savedError;
|
|
||||||
|
|
||||||
switch (source->type) {
|
switch (source->type) {
|
||||||
case VIR_DOMAIN_CHR_TYPE_PTY:
|
case VIR_DOMAIN_CHR_TYPE_PTY:
|
||||||
|
@ -434,15 +433,10 @@ int virChrdevOpen(virChrdevsPtr devs,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
savedError = virSaveLastError();
|
|
||||||
|
|
||||||
if (added)
|
if (added)
|
||||||
virHashRemoveEntry(devs->hash, path);
|
virHashRemoveEntry(devs->hash, path);
|
||||||
else
|
else
|
||||||
virStreamFree(st);
|
virObjectUnref(st);
|
||||||
|
|
||||||
virSetError(savedError);
|
|
||||||
virFreeError(savedError);
|
|
||||||
|
|
||||||
if (cbdata)
|
if (cbdata)
|
||||||
VIR_FREE(cbdata->path);
|
VIR_FREE(cbdata->path);
|
||||||
|
|
|
@ -187,8 +187,7 @@ static void virFDStreamEvent(int watch ATTRIBUTE_UNUSED,
|
||||||
|
|
||||||
static void virFDStreamCallbackFree(void *opaque)
|
static void virFDStreamCallbackFree(void *opaque)
|
||||||
{
|
{
|
||||||
virStreamPtr st = opaque;
|
virObjectUnref(opaque);
|
||||||
virStreamFree(st);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5691,7 +5691,7 @@ static void remoteStreamCallbackFree(void *opaque)
|
||||||
if (!cbdata->cb && cbdata->ff)
|
if (!cbdata->cb && cbdata->ff)
|
||||||
(cbdata->ff)(cbdata->opaque);
|
(cbdata->ff)(cbdata->opaque);
|
||||||
|
|
||||||
virStreamFree(cbdata->st);
|
virObjectUnref(cbdata->st);
|
||||||
VIR_FREE(opaque);
|
VIR_FREE(opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue