]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/vlan: paranoia about type safety
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 May 2023 02:06:35 +0000 (11:06 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 May 2023 02:06:43 +0000 (11:06 +0900)
No functional change, as the struct is defined as the following:
```
struct ifla_vlan_qos_mapping {
      __u32 from;
      __u32 to;
};
```

src/network/netdev/vlan.c

index d61e9486abc47917c23b8cdb0d3378361977eb29..5eb36ef6801f3fe4ea9511d7e366fb6667c0239f 100644 (file)
@@ -144,6 +144,7 @@ int config_parse_vlan_qos_maps(
         for (const char *p = rvalue;;) {
                 _cleanup_free_ struct ifla_vlan_qos_mapping *m = NULL;
                 _cleanup_free_ char *w = NULL;
+                unsigned from, to;
 
                 r = extract_first_word(&p, &w, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
                 if (r == -ENOMEM)
@@ -155,16 +156,21 @@ int config_parse_vlan_qos_maps(
                 if (r == 0)
                         return 0;
 
-                m = new0(struct ifla_vlan_qos_mapping, 1);
-                if (!m)
-                        return log_oom();
-
-                r = parse_range(w, &m->from, &m->to);
+                r = parse_range(w, &from, &to);
                 if (r < 0) {
                         log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, w);
                         continue;
                 }
 
+                m = new(struct ifla_vlan_qos_mapping, 1);
+                if (!m)
+                        return log_oom();
+
+                *m = (struct ifla_vlan_qos_mapping) {
+                        .from = from,
+                        .to = to,
+                };
+
                 r = set_ensure_consume(s, &vlan_qos_maps_hash_ops, TAKE_PTR(m));
                 if (r < 0) {
                         log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to store %s, ignoring: %s", lvalue, w);