emulator: Fix the unchecked return value

This patch fixes the unchecked return value.
This commit is contained in:
Tedd Ho-Jeong An 2020-11-20 12:07:10 -08:00 committed by Luiz Augusto von Dentz
parent 66b360a5ba
commit 8d23082905
2 changed files with 13 additions and 3 deletions

View File

@ -115,7 +115,10 @@ static int create_rx_socket(void)
if (fd < 0)
return -1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
close(fd);
return -1;
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
@ -138,7 +141,10 @@ static int create_tx_socket(void)
if (fd < 0)
return -1;
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt));
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt)) < 0) {
close(fd);
return -1;
}
return fd;
}

View File

@ -322,7 +322,11 @@ static int open_tcp(void)
return -1;
}
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
perror("Failed to set socket option");
close(fd);
return -1;
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;