1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.unix: use byte() instead of u16() cast for addr.sun_family

This commit is contained in:
Delyan Angelov 2022-02-18 13:47:12 +02:00
parent fad254dcce
commit d86b18844e

View File

@ -62,7 +62,7 @@ fn (mut s StreamSocket) connect(a string) ? {
} }
mut addr := C.sockaddr_un{} mut addr := C.sockaddr_un{}
unsafe { C.memset(&addr, 0, sizeof(C.sockaddr_un)) } unsafe { C.memset(&addr, 0, sizeof(C.sockaddr_un)) }
addr.sun_family = u16(C.AF_UNIX) addr.sun_family = byte(C.AF_UNIX)
unsafe { C.strncpy(&addr.sun_path[0], &char(a.str), max_sun_path) } unsafe { C.strncpy(&addr.sun_path[0], &char(a.str), max_sun_path) }
size := C.SUN_LEN(&addr) size := C.SUN_LEN(&addr)
res := C.connect(s.handle, voidptr(&addr), size) res := C.connect(s.handle, voidptr(&addr), size)
@ -94,7 +94,7 @@ pub fn listen_stream(sock string) ?&StreamListener {
s.path = sock s.path = sock
mut addr := C.sockaddr_un{} mut addr := C.sockaddr_un{}
unsafe { C.memset(&addr, 0, sizeof(C.sockaddr_un)) } unsafe { C.memset(&addr, 0, sizeof(C.sockaddr_un)) }
addr.sun_family = u16(C.AF_UNIX) addr.sun_family = byte(C.AF_UNIX)
unsafe { C.strncpy(&addr.sun_path[0], &char(sock.str), max_sun_path) } unsafe { C.strncpy(&addr.sun_path[0], &char(sock.str), max_sun_path) }
size := C.SUN_LEN(&addr) size := C.SUN_LEN(&addr)
if os.exists(sock) { if os.exists(sock) {