Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/tscore/ink_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

#include "tscore/ink_apidefs.h"

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, const void *optval, int optlevel);
int safe_getsockopt(int s, int level, int optname, void *optval, int *optlevel);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to mirror the setsockopt API then shouldn't it be const void * and socklen_t for the length?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

int safe_bind(int s, struct sockaddr const *name, int namelen);
int safe_listen(int s, int backlog);
int safe_getsockname(int s, struct sockaddr *name, int *namelen);
Expand Down
4 changes: 2 additions & 2 deletions src/tscore/ink_sock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ check_valid_sockaddr(sockaddr *sa, char *file, int line)
#endif

int
safe_setsockopt(int s, int level, int optname, char *optval, int optlevel)
safe_setsockopt(int s, int level, int optname, const void *optval, int optlevel)
{
int r;
do {
Expand All @@ -69,7 +69,7 @@ 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)
safe_getsockopt(int s, int level, int optname, void *optval, int *optlevel)
{
int r;
do {
Expand Down