1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

Userland: Get rid of the OwnPtr<...> boilerplate code for IPC handlers

This commit is contained in:
Gunnar Beutner 2021-05-02 04:39:36 +02:00 committed by Andreas Kling
parent 1a015dc379
commit 7cf2839a26
33 changed files with 389 additions and 385 deletions

View file

@ -28,22 +28,22 @@ void ClientConnection::die()
s_connections.remove(client_id());
}
OwnPtr<Messages::LookupServer::LookupNameResponse> ClientConnection::handle(const Messages::LookupServer::LookupName& message)
Messages::LookupServer::LookupNameResponse ClientConnection::handle(const Messages::LookupServer::LookupName& message)
{
auto answers = LookupServer::the().lookup(message.name(), T_A);
if (answers.is_empty())
return make<Messages::LookupServer::LookupNameResponse>(1, Vector<String>());
return { 1, Vector<String>() };
Vector<String> addresses;
for (auto& answer : answers) {
addresses.append(answer.record_data());
}
return make<Messages::LookupServer::LookupNameResponse>(0, move(addresses));
return { 0, move(addresses) };
}
OwnPtr<Messages::LookupServer::LookupAddressResponse> ClientConnection::handle(const Messages::LookupServer::LookupAddress& message)
Messages::LookupServer::LookupAddressResponse ClientConnection::handle(const Messages::LookupServer::LookupAddress& message)
{
if (message.address().length() != 4)
return make<Messages::LookupServer::LookupAddressResponse>(1, String());
return { 1, String() };
IPv4Address address { (const u8*)message.address().characters() };
auto name = String::formatted("{}.{}.{}.{}.in-addr.arpa",
address[3],
@ -52,7 +52,7 @@ OwnPtr<Messages::LookupServer::LookupAddressResponse> ClientConnection::handle(c
address[0]);
auto answers = LookupServer::the().lookup(name, T_PTR);
if (answers.is_empty())
return make<Messages::LookupServer::LookupAddressResponse>(1, String());
return make<Messages::LookupServer::LookupAddressResponse>(0, answers[0].record_data());
return { 1, String() };
return { 0, answers[0].record_data() };
}
}