summaryrefslogtreecommitdiff
path: root/Userland/Services/LookupServer
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-06 13:37:46 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-06 13:37:46 +0200
commit6024617df383bda00241c62d5cf3507a9c7c846c (patch)
treebf60bc8d42386e44887c4d3302d9e4850d11c325 /Userland/Services/LookupServer
parentf0629e29c988faf1a84cd38a6283ab8e3be5ad52 (diff)
downloadserenity-6024617df383bda00241c62d5cf3507a9c7c846c.zip
LookupServer: Remove some unnecessary "rc" temporaries
Diffstat (limited to 'Userland/Services/LookupServer')
-rw-r--r--Userland/Services/LookupServer/MulticastDNS.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/Userland/Services/LookupServer/MulticastDNS.cpp b/Userland/Services/LookupServer/MulticastDNS.cpp
index 99293e0c7d..768679af1a 100644
--- a/Userland/Services/LookupServer/MulticastDNS.cpp
+++ b/Userland/Services/LookupServer/MulticastDNS.cpp
@@ -23,24 +23,21 @@ MulticastDNS::MulticastDNS(Object* parent)
, m_hostname("courage.local")
{
char buffer[HOST_NAME_MAX];
- int rc = gethostname(buffer, sizeof(buffer));
- if (rc < 0) {
+ if (gethostname(buffer, sizeof(buffer)) < 0) {
perror("gethostname");
} else {
m_hostname = String::formatted("{}.local", buffer);
}
u8 zero = 0;
- rc = setsockopt(fd(), IPPROTO_IP, IP_MULTICAST_LOOP, &zero, 1);
- if (rc < 0)
+ if (setsockopt(fd(), IPPROTO_IP, IP_MULTICAST_LOOP, &zero, 1) < 0)
perror("setsockopt(IP_MULTICAST_LOOP)");
ip_mreq mreq = {
mdns_addr.sin_addr,
{ htonl(INADDR_ANY) },
};
- rc = setsockopt(fd(), IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
- if (rc < 0)
- perror("setsockopt(IP_ADD_MEMBESHIP)");
+ if (setsockopt(fd(), IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
+ perror("setsockopt(IP_ADD_MEMBERSHIP)");
bind(IPv4Address(), 5353);
@@ -98,8 +95,7 @@ void MulticastDNS::announce()
response.add_answer(answer);
}
- int rc = emit_packet(response);
- if (rc < 0)
+ if (emit_packet(response) < 0)
perror("Failed to emit response packet");
}
@@ -147,8 +143,7 @@ Vector<DNSAnswer> MulticastDNS::lookup(const DNSName& name, unsigned short recor
request.set_is_query();
request.add_question({ name, record_type, C_IN });
- int rc = emit_packet(request);
- if (rc < 0) {
+ if (emit_packet(request) < 0) {
perror("failed to emit request packet");
return {};
}
@@ -159,7 +154,7 @@ Vector<DNSAnswer> MulticastDNS::lookup(const DNSName& name, unsigned short recor
// the main loop while we wait for a response.
while (true) {
pollfd pfd { fd(), POLLIN, 0 };
- rc = poll(&pfd, 1, 1000);
+ auto rc = poll(&pfd, 1, 1000);
if (rc < 0) {
perror("poll");
} else if (rc == 0) {