Skip to contentSkip to conversation

test/helpers: fix socket length type

PATCH Applied Gabriel Krisman Bertazi 2 participants 2 messages Jan 18, 2023 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/helpers: fix socket length type

t_create_socket_pair uses size_t for paddrlen, which is uint64 on 64-bit architecture, while the network syscalls expect uint32. The implicit cast is always safe for little-endian here due to the structure format, its small size and the fact it was previously zeroed - so the test succeeds.

Still, on BE machines, our CI caught a few tests crashing on connect(). For instance:

localhost:~/liburing/test # ./send_recv.t
connect failed
test_invalid failed

---
 test/helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/helpers.c +1 -1
index 869e90342f9a..37ba67c070c8 100644
@@ -173,7 +173,7 @@ int t_create_socket_pair(int fd[2], bool stream)
 	int val;
 	struct sockaddr_in serv_addr;
 	struct sockaddr *paddr;
-	size_t paddrlen;
+	socklen_t paddrlen;
 
 	type |= SOCK_CLOEXEC;
 	fd[0] = socket(AF_INET, type, 0);
Signature · 1 line
2.35.3
maintainer Applied
#1 lore raw
Quoted 10 lines · Gabriel Krisman Bertazi

t_create_socket_pair uses size_t for paddrlen, which is uint64 on 64-bit architecture, while the network syscalls expect uint32. The implicit cast is always safe for little-endian here due to the structure format, its small size and the fact it was previously zeroed - so the test succeeds.

Still, on BE machines, our CI caught a few tests crashing on connect(). For instance:

[...]

Applied, thanks!

[1/1] test/helpers: fix socket length type

      commit: b5caa618565c0c6d0053f7b1bae2423cd317660c

Best regards,

Signature · 1 line
Jens Axboe