Commit eaf2c46
committed
Merge bitcoin/bitcoin#33378: Remove unnecessary casts when calling socket operations
67f632b net: remove unnecessary casts in socket operations (Matthew Zipkin)
Pull request description:
During review of bitcoin/bitcoin#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 bitcoin/bitcoin#24357 and bitcoin/bitcoin#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 bitcoin/bitcoin#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
```
int getsockopt(
[in] SOCKET s,
[in] int level,
[in] int optname,
[out] char *optval,
[in, out] int *optlen
);
```
but on POSIX the argument is `void*`:
https://www.man7.org/linux/man-pages/man2/getsockopt.2.html
```
int getsockopt(socklen *restrict optlen;
int sockfd, int level, int optname,
void optval[_Nullable restrict *optlen],
socklen_t *restrict optlen);
```
ACKs for top commit:
Raimo33:
ACK 67f632b
achow101:
ACK 67f632b
hodlinator:
ACK 67f632b
vasild:
ACK 67f632b
davidgumberg:
ACK bitcoin/bitcoin@67f632b
Tree-SHA512: c326d7242698b8d4d019f630fb6281398da2773c4e5aad1e3bba093a012c2119ad8815f42bd009e61a9a90db9b8e6ed5c75174aac059c9df83dd3aa5618a9ba6File tree
5 files changed
+8
-16
lines changed- src
- compat
- test
5 files changed
+8
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | 78 | | |
87 | 79 | | |
88 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1638 | 1638 | | |
1639 | 1639 | | |
1640 | 1640 | | |
1641 | | - | |
| 1641 | + | |
1642 | 1642 | | |
1643 | 1643 | | |
1644 | 1644 | | |
| |||
3139 | 3139 | | |
3140 | 3140 | | |
3141 | 3141 | | |
3142 | | - | |
| 3142 | + | |
3143 | 3143 | | |
3144 | 3144 | | |
3145 | 3145 | | |
| |||
3148 | 3148 | | |
3149 | 3149 | | |
3150 | 3150 | | |
3151 | | - | |
| 3151 | + | |
3152 | 3152 | | |
3153 | 3153 | | |
3154 | 3154 | | |
3155 | 3155 | | |
3156 | 3156 | | |
3157 | 3157 | | |
3158 | | - | |
| 3158 | + | |
3159 | 3159 | | |
3160 | 3160 | | |
3161 | 3161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
554 | | - | |
| 554 | + | |
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
| 623 | + | |
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
0 commit comments