diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-08-21 14:20:00 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-08-21 11:59:56 +0200 |
commit | ceea52ca9310054cdc822552c4066073bd513ac4 (patch) | |
tree | d61c89f177f61b4347393c243e5269bb63f859df /conf.c | |
parent | 905ecd2b0b8a6ab68b66017ec47e094253233e74 (diff) | |
download | passt-ceea52ca9310054cdc822552c4066073bd513ac4.tar passt-ceea52ca9310054cdc822552c4066073bd513ac4.tar.gz passt-ceea52ca9310054cdc822552c4066073bd513ac4.tar.bz2 passt-ceea52ca9310054cdc822552c4066073bd513ac4.tar.lz passt-ceea52ca9310054cdc822552c4066073bd513ac4.tar.xz passt-ceea52ca9310054cdc822552c4066073bd513ac4.tar.zst passt-ceea52ca9310054cdc822552c4066073bd513ac4.zip |
treewide: Use struct assignment instead of memcpy() for IP addresses
We rely on C11 already, so we can use clearer and more type-checkable
struct assignment instead of mempcy() for copying IP addresses around.
This exposes some "pointer could be const" warnings from cppcheck, so
address those too.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -389,14 +389,14 @@ static void add_dns6(struct ctx *c, /* Guest or container can only access local addresses via redirect */ if (IN6_IS_ADDR_LOOPBACK(addr)) { if (!c->no_map_gw) { - memcpy(*conf, &c->ip6.gw, sizeof(**conf)); + **conf = c->ip6.gw; (*conf)++; if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns_match)) - memcpy(&c->ip6.dns_match, addr, sizeof(*addr)); + c->ip6.dns_match = *addr; } } else { - memcpy(*conf, addr, sizeof(**conf)); + **conf = *addr; (*conf)++; } @@ -632,7 +632,7 @@ static unsigned int conf_ip4(unsigned int ifi, ip4->prefix_len = 32; } - memcpy(&ip4->addr_seen, &ip4->addr, sizeof(ip4->addr_seen)); + ip4->addr_seen = ip4->addr; if (MAC_IS_ZERO(mac)) { int rc = nl_link_get_mac(nl_sock, ifi, mac); @@ -693,8 +693,8 @@ static unsigned int conf_ip6(unsigned int ifi, return 0; } - memcpy(&ip6->addr_seen, &ip6->addr, sizeof(ip6->addr)); - memcpy(&ip6->addr_ll_seen, &ip6->addr_ll, sizeof(ip6->addr_ll)); + ip6->addr_seen = ip6->addr; + ip6->addr_ll_seen = ip6->addr_ll; if (MAC_IS_ZERO(mac)) { rc = nl_link_get_mac(nl_sock, ifi, mac); |