Skip to content

Commit a07e07c

Browse files
committed
network: tunnel: reduce indentation in config_parse_encap_limit()
1 parent 59c8bef commit a07e07c

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/network/netdev/netdev-gperf.gperf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Tunnel.DiscoverPathMTU, config_parse_bool,
7979
Tunnel.Mode, config_parse_ip6tnl_mode, 0, offsetof(Tunnel, ip6tnl_mode)
8080
Tunnel.IPv6FlowLabel, config_parse_ipv6_flowlabel, 0, 0
8181
Tunnel.CopyDSCP, config_parse_bool, 0, offsetof(Tunnel, copy_dscp)
82-
Tunnel.EncapsulationLimit, config_parse_encap_limit, 0, offsetof(Tunnel, encap_limit)
82+
Tunnel.EncapsulationLimit, config_parse_encap_limit, 0, 0
8383
Tunnel.Independent, config_parse_bool, 0, offsetof(Tunnel, independent)
8484
Tunnel.AssignToLoopback, config_parse_bool, 0, offsetof(Tunnel, assign_to_loopback)
8585
Tunnel.AllowLocalRemote, config_parse_tristate, 0, offsetof(Tunnel, allow_localremote)

src/network/netdev/tunnel.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -885,31 +885,33 @@ int config_parse_encap_limit(
885885
void *data,
886886
void *userdata) {
887887

888-
Tunnel *t = userdata;
889-
int k = 0;
890-
int r;
888+
Tunnel *t = ASSERT_PTR(userdata);
889+
int k, r;
891890

892891
assert(filename);
893-
assert(lvalue);
894892
assert(rvalue);
895893

896-
if (streq(rvalue, "none"))
894+
if (streq(rvalue, "none")) {
897895
t->flags |= IP6_TNL_F_IGN_ENCAP_LIMIT;
898-
else {
899-
r = safe_atoi(rvalue, &k);
900-
if (r < 0) {
901-
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Tunnel Encapsulation Limit option, ignoring: %s", rvalue);
902-
return 0;
903-
}
896+
t->encap_limit = 0;
897+
return 0;
898+
}
904899

905-
if (k > 255 || k < 0)
906-
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid Tunnel Encapsulation value, ignoring: %d", k);
907-
else {
908-
t->encap_limit = k;
909-
t->flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
910-
}
900+
r = safe_atoi(rvalue, &k);
901+
if (r < 0) {
902+
log_syntax(unit, LOG_WARNING, filename, line, r,
903+
"Failed to parse Tunnel Encapsulation Limit option, ignoring assignment: %s", rvalue);
904+
return 0;
905+
}
906+
907+
if (k > 255 || k < 0) {
908+
log_syntax(unit, LOG_WARNING, filename, line, 0,
909+
"Invalid Tunnel Encapsulation value, ignoring assignment: %d", k);
910+
return 0;
911911
}
912912

913+
t->encap_limit = k;
914+
t->flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
913915
return 0;
914916
}
915917

0 commit comments

Comments
 (0)