must be explicit when using unions otherwise size mispatch could occur (#4256)

* must be explicit when using unions otherwise size mispatch could occur

* fixed formatting
This commit is contained in:
kevin-f-ortega 2025-10-06 10:18:20 -07:00 committed by GitHub
parent 7fbe13086a
commit 0a945a55c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -217,7 +217,15 @@ SocketIpStatus IpSocket::handleZeroReturn() {
SocketIpStatus IpSocket::setupSocketOptions(int socketFd) {
// Iterate over the socket options and set them
for (const auto& options : IP_SOCKET_OPTIONS) {
if (setsockopt(socketFd, options.level, options.option, &options.value, sizeof(options.value))) {
int status = 0;
if (options.type == SOCK_OPT_INT) {
status = setsockopt(socketFd, options.level, options.option, &options.value.intVal,
sizeof(options.value.intVal));
} else {
status = setsockopt(socketFd, options.level, options.option, &options.value.sizeVal,
sizeof(options.value.sizeVal));
}
if (status) {
return SOCK_FAILED_TO_SET_SOCKET_OPTIONS;
}
}