During review of #32747 several casting operations were questioned in existing code that had been copied or moved. That lead me to find a few other similar casts in the codebase.
It turns out that since the Sock class wraps syscalls with its own internal casting (see #24357 and #20788 written in 2020-2022) we no longer need to cast the arguments when calling these functions. The original argument-casts are old and were cleaned up a bit in #12855 written in 2018.
The casting is only needed for windows compatibility, where those syscalls require a data argument to be of type char* specifically:
https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockopt
0int getsockopt(
1  [in]      SOCKET s,
2  [in]      int    level,
3  [in]      int    optname,
4  [out]     char   *optval,
5  [in, out] int    *optlen
6);
but on POSIX the argument is void*:
https://www.man7.org/linux/man-pages/man2/getsockopt.2.html
0       int getsockopt(socklen *restrict optlen;
1                      int sockfd, int level, int optname,
2                      void optval[_Nullable restrict *optlen],
3                      socklen_t *restrict optlen);