From 10cde499b5f3bfaa668c3fbce1f15da7b299b55d Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Sun, 8 Dec 2024 17:00:11 +0000 Subject: [PATCH] odbc: Make init_fake_server more similars TODO, reuse Signed-off-by: Frediano Ziglio --- src/odbc/unittests/timeout3.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/odbc/unittests/timeout3.c b/src/odbc/unittests/timeout3.c index 1c403b9c4..3d225346e 100644 --- a/src/odbc/unittests/timeout3.c +++ b/src/odbc/unittests/timeout3.c @@ -50,7 +50,6 @@ init_fake_server(int ip_port) { struct sockaddr_in sin; TDS_SYS_SOCKET s; - int err; memset(&sin, 0, sizeof(sin)); sin.sin_addr.s_addr = INADDR_ANY; @@ -66,9 +65,12 @@ init_fake_server(int ip_port) CLOSESOCKET(s); return 1; } - listen(s, 5); - err = tds_thread_create(&fake_thread, fake_thread_proc, TDS_INT2PTR(s)); - if (err != 0) { + if (listen(s, 5) < 0) { + perror("listen"); + CLOSESOCKET(s); + return 1; + } + if (tds_thread_create(&fake_thread, fake_thread_proc, TDS_INT2PTR(s)) != 0) { perror("tds_thread_create"); exit(1); }