提交 b396fae9 编写于 作者: P Pavel Hrdina

Fix issue found by coverity and cleanup

Coverity found an issue in lxc_driver and uml_driver that we don't
check the return value of register functions.

I've also updated all other places and unify the way we check the
return value.
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 fbf14e82
...@@ -715,7 +715,9 @@ static virStateDriver bhyveStateDriver = { ...@@ -715,7 +715,9 @@ static virStateDriver bhyveStateDriver = {
int int
bhyveRegister(void) bhyveRegister(void)
{ {
virRegisterDriver(&bhyveDriver); if (virRegisterDriver(&bhyveDriver) < 0)
virRegisterStateDriver(&bhyveStateDriver); return -1;
if (virRegisterStateDriver(&bhyveStateDriver) < 0)
return -1;
return 0; return 0;
} }
...@@ -1194,6 +1194,7 @@ int netcfIfaceRegister(void) { ...@@ -1194,6 +1194,7 @@ int netcfIfaceRegister(void) {
_("failed to register netcf interface driver")); _("failed to register netcf interface driver"));
return -1; return -1;
} }
virRegisterStateDriver(&interfaceStateDriver); if (virRegisterStateDriver(&interfaceStateDriver) < 0)
return -1;
return 0; return 0;
} }
...@@ -5767,7 +5767,9 @@ static virStateDriver lxcStateDriver = { ...@@ -5767,7 +5767,9 @@ static virStateDriver lxcStateDriver = {
int lxcRegister(void) int lxcRegister(void)
{ {
virRegisterDriver(&lxcDriver); if (virRegisterDriver(&lxcDriver) < 0)
virRegisterStateDriver(&lxcStateDriver); return -1;
if (virRegisterStateDriver(&lxcStateDriver) < 0)
return -1;
return 0; return 0;
} }
...@@ -3232,7 +3232,8 @@ static virStateDriver networkStateDriver = { ...@@ -3232,7 +3232,8 @@ static virStateDriver networkStateDriver = {
int networkRegister(void) { int networkRegister(void) {
if (virRegisterNetworkDriver(&networkDriver) < 0) if (virRegisterNetworkDriver(&networkDriver) < 0)
return -1; return -1;
virRegisterStateDriver(&networkStateDriver); if (virRegisterStateDriver(&networkStateDriver) < 0)
return -1;
return 0; return 0;
} }
......
...@@ -716,8 +716,11 @@ static virDomainConfNWFilterDriver domainNWFilterDriver = { ...@@ -716,8 +716,11 @@ static virDomainConfNWFilterDriver domainNWFilterDriver = {
int nwfilterRegister(void) { int nwfilterRegister(void) {
virRegisterNWFilterDriver(&nwfilterDriver); if (virRegisterNWFilterDriver(&nwfilterDriver) < 0)
virRegisterStateDriver(&stateDriver); return -1;
virDomainConfNWFilterRegister(&domainNWFilterDriver); if (virRegisterStateDriver(&stateDriver) < 0)
return -1;
if (virDomainConfNWFilterRegister(&domainNWFilterDriver) < 0)
return -1;
return 0; return 0;
} }
...@@ -16796,7 +16796,9 @@ static virStateDriver qemuStateDriver = { ...@@ -16796,7 +16796,9 @@ static virStateDriver qemuStateDriver = {
}; };
int qemuRegister(void) { int qemuRegister(void) {
virRegisterDriver(&qemuDriver); if (virRegisterDriver(&qemuDriver) < 0)
virRegisterStateDriver(&qemuStateDriver); return -1;
if (virRegisterStateDriver(&qemuStateDriver) < 0)
return -1;
return 0; return 0;
} }
...@@ -7825,15 +7825,23 @@ remoteRegister(void) ...@@ -7825,15 +7825,23 @@ remoteRegister(void)
{ {
remoteDriver = &remote_driver; remoteDriver = &remote_driver;
if (virRegisterDriver(&remote_driver) == -1) return -1; if (virRegisterDriver(&remote_driver) < 0)
if (virRegisterNetworkDriver(&network_driver) == -1) return -1; return -1;
if (virRegisterInterfaceDriver(&interface_driver) == -1) return -1; if (virRegisterNetworkDriver(&network_driver) < 0)
if (virRegisterStorageDriver(&storage_driver) == -1) return -1; return -1;
if (virRegisterNodeDeviceDriver(&node_device_driver) == -1) return -1; if (virRegisterInterfaceDriver(&interface_driver) < 0)
if (virRegisterSecretDriver(&secret_driver) == -1) return -1; return -1;
if (virRegisterNWFilterDriver(&nwfilter_driver) == -1) return -1; if (virRegisterStorageDriver(&storage_driver) < 0)
return -1;
if (virRegisterNodeDeviceDriver(&node_device_driver) < 0)
return -1;
if (virRegisterSecretDriver(&secret_driver) < 0)
return -1;
if (virRegisterNWFilterDriver(&nwfilter_driver) < 0)
return -1;
#ifdef WITH_LIBVIRTD #ifdef WITH_LIBVIRTD
if (virRegisterStateDriver(&state_driver) == -1) return -1; if (virRegisterStateDriver(&state_driver) == -1) < 0)
return -1;
#endif #endif
return 0; return 0;
......
...@@ -1194,7 +1194,9 @@ static virStateDriver stateDriver = { ...@@ -1194,7 +1194,9 @@ static virStateDriver stateDriver = {
int int
secretRegister(void) secretRegister(void)
{ {
virRegisterSecretDriver(&secretDriver); if (virRegisterSecretDriver(&secretDriver) < 0)
virRegisterStateDriver(&stateDriver); return -1;
if (virRegisterStateDriver(&stateDriver) < 0)
return -1;
return 0; return 0;
} }
...@@ -2696,7 +2696,8 @@ int storageRegister(void) ...@@ -2696,7 +2696,8 @@ int storageRegister(void)
{ {
if (virRegisterStorageDriver(&storageDriver) < 0) if (virRegisterStorageDriver(&storageDriver) < 0)
return -1; return -1;
virRegisterStateDriver(&stateDriver); if (virRegisterStateDriver(&stateDriver) < 0)
return -1;
return 0; return 0;
} }
......
...@@ -2909,7 +2909,9 @@ static virStateDriver umlStateDriver = { ...@@ -2909,7 +2909,9 @@ static virStateDriver umlStateDriver = {
}; };
int umlRegister(void) { int umlRegister(void) {
virRegisterDriver(&umlDriver); if (virRegisterDriver(&umlDriver) < 0)
virRegisterStateDriver(&umlStateDriver); return -1;
if (virRegisterStateDriver(&umlStateDriver) < 0)
return -1;
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册