hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 827c5ef83b54e3d00d55e87ab4e8f6141f3ade4d
parent 813b4792a247a86da3fc1c78fcd54f2cca21446d
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon,  1 Nov 2021 11:29:28 +0100

net::ip: initialize complete structs in to_native

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mnet/ip/+freebsd.ha | 32++++++++++++++++++++------------
Mnet/ip/+linux.ha | 28++++++++++++++++++----------
2 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/net/ip/+freebsd.ha b/net/ip/+freebsd.ha @@ -4,19 +4,27 @@ use endian; export fn to_native(a: addr, port: u16) rt::sockaddr = { match (a) { case v4: addr4 => - return rt::sockaddr { in = rt::sockaddr_in { - sin_len = size(rt::in_addr): u8, - sin_family = rt::AF_INET, - sin_port = endian::htonu16(port), - sin_addr = rt::in_addr { s_addr = *(&v4[0]: *void: *u32) }, - } }; + return rt::sockaddr { + in = rt::sockaddr_in { + sin_len = size(rt::in_addr): u8, + sin_family = rt::AF_INET, + sin_port = endian::htonu16(port), + sin_addr = rt::in_addr { s_addr = *(&v4[0]: *void: *u32) }, + ... + }, + ... + }; case v6: addr6 => - return rt::sockaddr { in6 = rt::sockaddr_in6 { - sin6_len = size(rt::in6_addr): u8, - sin6_family = rt::AF_INET6, - sin6_port = endian::htonu16(port), - sin6_addr = rt::in6_addr { s6_addr = v6 }, - } }; + return rt::sockaddr { + in6 = rt::sockaddr_in6 { + sin6_len = size(rt::in6_addr): u8, + sin6_family = rt::AF_INET6, + sin6_port = endian::htonu16(port), + sin6_addr = rt::in6_addr { s6_addr = v6 }, + ... + }, + ... + }; }; }; diff --git a/net/ip/+linux.ha b/net/ip/+linux.ha @@ -4,17 +4,25 @@ use endian; export fn to_native(a: addr, port: u16) rt::sockaddr = { match (a) { case v4: addr4 => - return rt::sockaddr { in = rt::sockaddr_in { - sin_family = rt::AF_INET, - sin_port = endian::htonu16(port), - sin_addr = rt::in_addr { s_addr = *(&v4[0]: *void: *u32) }, - } }; + return rt::sockaddr { + in = rt::sockaddr_in { + sin_family = rt::AF_INET, + sin_port = endian::htonu16(port), + sin_addr = rt::in_addr { s_addr = *(&v4[0]: *void: *u32) }, + ... + }, + ... + }; case v6: addr6 => - return rt::sockaddr { in6 = rt::sockaddr_in6 { - sin6_family = rt::AF_INET6, - sin6_port = endian::htonu16(port), - sin6_addr = rt::in6_addr { s6_addr = v6 }, - } }; + return rt::sockaddr { + in6 = rt::sockaddr_in6 { + sin6_family = rt::AF_INET6, + sin6_port = endian::htonu16(port), + sin6_addr = rt::in6_addr { s6_addr = v6 }, + ... + }, + ... + }; }; };