]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: tunnel: reduce indentation in config_parse_encap_limit()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 1 Feb 2022 23:25:38 +0000 (08:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 3 Feb 2022 02:10:15 +0000 (11:10 +0900)
src/network/netdev/netdev-gperf.gperf
src/network/netdev/tunnel.c

index d03a4e57846a8aba59505649f78cca46c85e998f..a993e25867911f7627f424009525d989385d2244 100644 (file)
@@ -79,7 +79,7 @@ Tunnel.DiscoverPathMTU,                   config_parse_bool,
 Tunnel.Mode,                              config_parse_ip6tnl_mode,                  0,                             offsetof(Tunnel, ip6tnl_mode)
 Tunnel.IPv6FlowLabel,                     config_parse_ipv6_flowlabel,               0,                             0
 Tunnel.CopyDSCP,                          config_parse_bool,                         0,                             offsetof(Tunnel, copy_dscp)
-Tunnel.EncapsulationLimit,                config_parse_encap_limit,                  0,                             offsetof(Tunnel, encap_limit)
+Tunnel.EncapsulationLimit,                config_parse_encap_limit,                  0,                             0
 Tunnel.Independent,                       config_parse_bool,                         0,                             offsetof(Tunnel, independent)
 Tunnel.AssignToLoopback,                  config_parse_bool,                         0,                             offsetof(Tunnel, assign_to_loopback)
 Tunnel.AllowLocalRemote,                  config_parse_tristate,                     0,                             offsetof(Tunnel, allow_localremote)
index 8eb633549f91689aecc1c4336ace398af0f7c5a0..a70121efdac474d99ece6b43121a2b4aa7146652 100644 (file)
@@ -885,31 +885,33 @@ int config_parse_encap_limit(
                 void *data,
                 void *userdata) {
 
-        Tunnel *t = userdata;
-        int k = 0;
-        int r;
+        Tunnel *t = ASSERT_PTR(userdata);
+        int k, r;
 
         assert(filename);
-        assert(lvalue);
         assert(rvalue);
 
-        if (streq(rvalue, "none"))
+        if (streq(rvalue, "none")) {
                 t->flags |= IP6_TNL_F_IGN_ENCAP_LIMIT;
-        else {
-                r = safe_atoi(rvalue, &k);
-                if (r < 0) {
-                        log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Tunnel Encapsulation Limit option, ignoring: %s", rvalue);
-                        return 0;
-                }
+                t->encap_limit = 0;
+                return 0;
+        }
 
-                if (k > 255 || k < 0)
-                        log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid Tunnel Encapsulation value, ignoring: %d", k);
-                else {
-                        t->encap_limit = k;
-                        t->flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
-                }
+        r = safe_atoi(rvalue, &k);
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r,
+                           "Failed to parse Tunnel Encapsulation Limit option, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        if (k > 255 || k < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid Tunnel Encapsulation value, ignoring assignment: %d", k);
+                return 0;
         }
 
+        t->encap_limit = k;
+        t->flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
         return 0;
 }