]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp: shorten code a bit
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 19 Oct 2021 11:22:56 +0000 (20:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 21 Oct 2021 13:39:43 +0000 (22:39 +0900)
src/libsystemd-network/dhcp-network.c

index 85059102b1c64955184f947d4dc5d066a68ff142..0e3814c6baa5ecce03425b867c243af1a8ad8533 100644 (file)
@@ -172,7 +172,6 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int
                 r = setsockopt_int(s, IPPROTO_IP, IP_TOS, ip_service_type);
         else
                 r = setsockopt_int(s, IPPROTO_IP, IP_TOS, IPTOS_CLASS_CS6);
-
         if (r < 0)
                 return r;
 
@@ -204,8 +203,7 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int
                         return r;
         }
 
-        r = bind(s, &src.sa, sizeof(src.in));
-        if (r < 0)
+        if (bind(s, &src.sa, sizeof(src.in)) < 0)
                 return -errno;
 
         return TAKE_FD(s);
@@ -213,14 +211,12 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int
 
 int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
                                  const void *packet, size_t len) {
-        int r;
 
         assert(link);
         assert(packet);
         assert(len);
 
-        r = sendto(s, packet, len, 0, &link->sa, SOCKADDR_LL_LEN(link->ll));
-        if (r < 0)
+        if (sendto(s, packet, len, 0, &link->sa, SOCKADDR_LL_LEN(link->ll)) < 0)
                 return -errno;
 
         return 0;
@@ -233,14 +229,12 @@ int dhcp_network_send_udp_socket(int s, be32_t address, uint16_t port,
                 .in.sin_port = htobe16(port),
                 .in.sin_addr.s_addr = address,
         };
-        int r;
 
         assert(s >= 0);
         assert(packet);
         assert(len);
 
-        r = sendto(s, packet, len, 0, &dest.sa, sizeof(dest.in));
-        if (r < 0)
+        if (sendto(s, packet, len, 0, &dest.sa, sizeof(dest.in)) < 0)
                 return -errno;
 
         return 0;