]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libsystemd-network: use normal style for error checking
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 14 May 2024 16:51:57 +0000 (18:51 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 14 May 2024 16:56:41 +0000 (18:56 +0200)
We generally use a flat list. The switch stmt was generating excessive
indentation.

src/libsystemd-network/icmp6-packet.c

index f447549dc86e3399b3751e204e053478d138cb63..02865a40c25e929745d72ef42c829b26abd3a81e 100644 (file)
@@ -113,20 +113,14 @@ int icmp6_packet_receive(int fd, ICMP6Packet **ret) {
                 return -ENOMEM;
 
         r = icmp6_receive(fd, p->raw_packet, p->raw_size, &p->sender_address, &p->timestamp);
+        if (r == -EADDRNOTAVAIL)
+                return log_debug_errno(r, "ICMPv6: Received a packet from neither link-local nor null address.");
+        if (r == -EMULTIHOP)
+                return log_debug_errno(r, "ICMPv6: Received a packet with an invalid hop limit.");
+        if (r == -EPFNOSUPPORT)
+                return log_debug_errno(r, "ICMPv6: Received a packet with an invalid source address.");
         if (r < 0)
-                switch (r) {
-                case -EADDRNOTAVAIL:
-                        return log_debug_errno(r, "ICMPv6: Received a packet from neither link-local nor null address.");
-
-                case -EMULTIHOP:
-                        return log_debug_errno(r, "ICMPv6: Received a packet with an invalid hop limit.");
-
-                case -EPFNOSUPPORT:
-                        return log_debug_errno(r, "ICMPv6: Received a packet with an invalid source address.");
-
-                default:
-                        return log_debug_errno(r, "ICMPv6: Unexpected error while receiving a packet: %m");
-                }
+                return log_debug_errno(r, "ICMPv6: Unexpected error while receiving a packet: %m");
 
         r = icmp6_packet_verify(p);
         if (r < 0)