On Sat, 11.04.15 18:39, Shawn Landden ([email protected]) wrote:

> we only access this as void* so there is no violation
> ---
>  src/libsystemd-network/sd-dhcp-client.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libsystemd-network/sd-dhcp-client.c 
> b/src/libsystemd-network/sd-dhcp-client.c
> index c44392e..bf57d4b 100644
> --- a/src/libsystemd-network/sd-dhcp-client.c
> +++ b/src/libsystemd-network/sd-dhcp-client.c
> @@ -1470,7 +1470,7 @@ static int client_receive_message_udp(sd_event_source 
> *s, int fd,
>          _cleanup_free_ DHCPMessage *message = NULL;
>          int buflen = 0, len, r;
>          const struct ether_addr zero_mac = { { 0, 0, 0, 0, 0, 0 } };
> -        const struct ether_addr *expected_chaddr = NULL;
> +        const void *expected_chaddr = NULL;
>          uint8_t expected_hlen = 0;
>  
>          assert(s);
> @@ -1515,7 +1515,7 @@ static int client_receive_message_udp(sd_event_source 
> *s, int fd,
>  
>          if (client->arp_type == ARPHRD_ETHER) {
>                  expected_hlen = ETH_ALEN;
> -                expected_chaddr = (const struct ether_addr *) 
> &client->mac_addr;
> +                expected_chaddr = &client->mac_addr;
>          } else {
>                 /* Non-ethernet links expect zero chaddr */
>                 expected_hlen = 0;

The right way to fix aliasing issues are unions. In this case, I
figure sd_dhcp_client should contain a union for the ethernet address,
containing the array for MAX_MAC_ADDR_LEN as well as a proper struct
ether_addr. it can even be an anonymous union. With that all aliasing
issues are gone, it would stay typesafe, and more elegant anyway.

Lennart

-- 
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to