Skip to content

Commit

Permalink
Fix strict aliasing violation ahead of clang update.
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Avlasov <[email protected]>
  • Loading branch information
yanavlasov committed Dec 7, 2023
1 parent 65bbace commit 8f832ce
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/mocks/api/mocks.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "mocks.h"

#include <cstring>

#include "source/common/common/assert.h"
#include "source/common/common/lock_guard.h"

Expand Down Expand Up @@ -66,7 +68,10 @@ SysCallIntResult MockOsSysCalls::setsockopt(os_fd_t sockfd, int level, int optna
}

if (optlen >= sizeof(int)) {
boolsockopts_[SockOptKey(sockfd, level, optname)] = !!*reinterpret_cast<const int*>(optval);
int val = 0;

memcpy(&val, optval, sizeof(int));
boolsockopts_[SockOptKey(sockfd, level, optname)] = (val != 0);
}
return SysCallIntResult{0, 0};
};
Expand Down

0 comments on commit 8f832ce

Please sign in to comment.