Change the function signature of safe_[get|set]sockopt#8331
Change the function signature of safe_[get|set]sockopt#8331maskit merged 2 commits intoapache:masterfrom
Conversation
The type of val argument for [get|set]sockopt is void*, but not char*. Some values don't fit into a char, and casting the pointer to char* causes compile error.
| int safe_setsockopt(int s, int level, int optname, char *optval, int optlevel); | ||
| int safe_getsockopt(int s, int level, int optname, char *optval, int *optlevel); | ||
| int safe_setsockopt(int s, int level, int optname, void *optval, int optlevel); | ||
| int safe_getsockopt(int s, int level, int optname, void *optval, int *optlevel); |
There was a problem hiding this comment.
If you are going to mirror the setsockopt API then shouldn't it be const void * and socklen_t for the length?
There was a problem hiding this comment.
I kept my change minimal.
If I change int * to socklen_t * I have to deal with the error below at all places that call safe_getsockopt. I could just reinterpret_cast at all the places but I guess some of the places can declare variables as unsigned int and don't need any casts. I don't want to check and fix that.
/Users/mkitajo/src/github.com/trafficserver/iocore/eventsystem/P_UnixSocketManager.h:482:11: error: no matching function for call to 'safe_getsockopt'
r = safe_getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&bsz, &bszsz);
^~~~~~~~~~~~~~~
../../include/tscore/ink_sock.h:38:5: note: candidate function not viable: no known conversion from 'int *' to 'socklen_t *' (aka 'unsigned int *') for 5th argument
int safe_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlevel);
^
I added const for optval for now.
bneradt
left a comment
There was a problem hiding this comment.
Sounds good to me. This is an improvement.
|
@bryancall Can you take another look? Changing |
|
This pull request has been automatically marked as stale because it has not had recent activity. Marking it stale to flag it for further consideration by the community. |
|
@bryancall I left this open for you because your comment was a change request, but I'm going to merge this with Brian's approval next week if there's no response. |
Suggested change is minor and there's no response.
* Change the function signature of safe_[get|set]sockopt The type of val argument for [get|set]sockopt is void*, but not char*. Some values don't fit into a char, and casting the pointer to char* causes compile error. * Add const (cherry picked from commit e0d0504)
|
Cherry-picked to v9.2.x |
* asf/9.2.x: Updated ChangeLog Prevent calling SSL_set_session in the middle of handshake (apache#8600) Change the function signature of safe_[get|set]sockopt (apache#8331) Revert fixes for apache#8539 (apache#8637) Update descriptions of sni.yaml.default (apache#8568)
The type of
optvalargument for [get|set]sockopt isvoid*, but notchar*.Some values don't fit into a
char, and casting the pointer tochar*causes compile error.