mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
rpc: assume private data callbacks are always non-NULL
Since we annotate the APIs are having non-NULL parameters, we can remove the checks for NULL in the code too. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
72874b2d11
commit
17398ccef3
@ -466,14 +466,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned long long id,
|
||||
now)))
|
||||
return NULL;
|
||||
|
||||
if (privNew) {
|
||||
if (!(client->privateData = privNew(client, privOpaque))) {
|
||||
virObjectUnref(client);
|
||||
return NULL;
|
||||
}
|
||||
client->privateDataFreeFunc = privFree;
|
||||
client->privateDataPreExecRestart = privPreExecRestart;
|
||||
if (!(client->privateData = privNew(client, privOpaque))) {
|
||||
virObjectUnref(client);
|
||||
return NULL;
|
||||
}
|
||||
client->privateDataFreeFunc = privFree;
|
||||
client->privateDataPreExecRestart = privPreExecRestart;
|
||||
|
||||
return client;
|
||||
}
|
||||
@ -580,18 +578,18 @@ virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr srv,
|
||||
}
|
||||
virObjectUnref(sock);
|
||||
|
||||
if (privNew) {
|
||||
if (!(child = virJSONValueObjectGet(object, "privateData"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Missing privateData field in JSON state document"));
|
||||
goto error;
|
||||
}
|
||||
if (!(client->privateData = privNew(client, child, privOpaque)))
|
||||
goto error;
|
||||
client->privateDataFreeFunc = privFree;
|
||||
client->privateDataPreExecRestart = privPreExecRestart;
|
||||
if (!(child = virJSONValueObjectGet(object, "privateData"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Missing privateData field in JSON state document"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(client->privateData = privNew(client, child, privOpaque)))
|
||||
goto error;
|
||||
|
||||
client->privateDataFreeFunc = privFree;
|
||||
client->privateDataPreExecRestart = privPreExecRestart;
|
||||
|
||||
|
||||
return client;
|
||||
|
||||
@ -637,14 +635,12 @@ virJSONValuePtr virNetServerClientPreExecRestart(virNetServerClientPtr client)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (client->privateData && client->privateDataPreExecRestart) {
|
||||
if (!(child = client->privateDataPreExecRestart(client, client->privateData)))
|
||||
goto error;
|
||||
if (!(child = client->privateDataPreExecRestart(client, client->privateData)))
|
||||
goto error;
|
||||
|
||||
if (virJSONValueObjectAppend(object, "privateData", child) < 0) {
|
||||
virJSONValueFree(child);
|
||||
goto error;
|
||||
}
|
||||
if (virJSONValueObjectAppend(object, "privateData", child) < 0) {
|
||||
virJSONValueFree(child);
|
||||
goto error;
|
||||
}
|
||||
|
||||
virObjectUnlock(client);
|
||||
@ -989,8 +985,7 @@ void virNetServerClientDispose(void *obj)
|
||||
PROBE(RPC_SERVER_CLIENT_DISPOSE,
|
||||
"client=%p", client);
|
||||
|
||||
if (client->privateData &&
|
||||
client->privateDataFreeFunc)
|
||||
if (client->privateData)
|
||||
client->privateDataFreeFunc(client->privateData);
|
||||
|
||||
virObjectUnref(client->identity);
|
||||
|
Loading…
Reference in New Issue
Block a user