diff mbox series

[2/8] rt-tests: hackbench: Add error checking to connect and getsockname

Message ID 20221111195323.27402-2-jkacur@redhat.com
State New
Headers show
Series [1/8] rt-tests: Remove arbitrary num of threads limits | expand

Commit Message

John Kacur Nov. 11, 2022, 7:53 p.m. UTC
Add error checking around the calls connect and getsockname

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/hackbench/hackbench.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c
index 18c928480103..8c6d83520e57 100644
--- a/src/hackbench/hackbench.c
+++ b/src/hackbench/hackbench.c
@@ -130,14 +130,16 @@  static int inet_socketpair(int fds[2])
 
 	if (bind(s1, &sin, len) < 0)
 		barf("bind");
-	getsockname(s1, &sin, &len);
+	if (getsockname(s1, &sin, &len) < 0)
+		barf("getsockname");
 	if (listen(s1, 10) < 0)
 		barf("listen");
 	if (ioctl(s2, FIONBIO, &ul) < 0)
 		barf("ioctl");
 	if (ioctl(s1, FIONBIO, &ul) < 0)
 		barf("ioctl");
-	connect(s2, &sin, len);
+	if (connect(s2, &sin, len) < 0)
+		barf("connect");
 	if ((fds[0] = accept(s1, &sin, &len)) < 0)
 		barf("accept");
 	ul = 0;