Skip to content

Commit e9ba334

Browse files
authored
Tweak: Add prefix to non-static function names (ruby#12764)
to avoid conflicts with other functions. This was pointed out in ruby#11653 (comment) , but it was not fixed at that time.
1 parent cfca348 commit e9ba334

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

ext/socket/ipsocket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@ rsock_init_inetsock(VALUE self, VALUE remote_host, VALUE remote_serv, VALUE loca
12171217
char *hostp, *portp;
12181218
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
12191219
int additional_flags = 0;
1220-
hostp = host_str(remote_host, hbuf, sizeof(hbuf), &additional_flags);
1221-
portp = port_str(remote_serv, pbuf, sizeof(pbuf), &additional_flags);
1220+
hostp = raddrinfo_host_str(remote_host, hbuf, sizeof(hbuf), &additional_flags);
1221+
portp = raddrinfo_port_str(remote_serv, pbuf, sizeof(pbuf), &additional_flags);
12221222

12231223
if (!is_specified_ip_address(hostp)) {
12241224
int target_families[2] = { 0, 0 };

ext/socket/raddrinfo.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ str_is_number(const char *p)
823823
rb_strlen_lit(name) == (len) && memcmp(ptr, name, len) == 0)
824824

825825
char*
826-
host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
826+
raddrinfo_host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
827827
{
828828
if (NIL_P(host)) {
829829
return NULL;
@@ -862,7 +862,7 @@ host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
862862
}
863863

864864
char*
865-
port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr)
865+
raddrinfo_port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr)
866866
{
867867
if (NIL_P(port)) {
868868
return 0;
@@ -914,7 +914,7 @@ rb_scheduler_getaddrinfo(VALUE scheduler, VALUE host, const char *service,
914914

915915
for(i=0; i<len; i++) {
916916
ip_address = rb_ary_entry(ip_addresses_array, i);
917-
hostp = host_str(ip_address, _hbuf, sizeof(_hbuf), &_additional_flags);
917+
hostp = raddrinfo_host_str(ip_address, _hbuf, sizeof(_hbuf), &_additional_flags);
918918
error = numeric_getaddrinfo(hostp, service, hints, &ai);
919919
if (error == 0) {
920920
if (!res_allocated) {
@@ -950,8 +950,8 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h
950950
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
951951
int additional_flags = 0;
952952

953-
hostp = host_str(host, hbuf, sizeof(hbuf), &additional_flags);
954-
portp = port_str(port, pbuf, sizeof(pbuf), &additional_flags);
953+
hostp = raddrinfo_host_str(host, hbuf, sizeof(hbuf), &additional_flags);
954+
portp = raddrinfo_port_str(port, pbuf, sizeof(pbuf), &additional_flags);
955955

956956
if (socktype_hack && hints->ai_socktype == 0 && str_is_number(portp)) {
957957
hints->ai_socktype = SOCK_DGRAM;
@@ -1137,7 +1137,7 @@ make_hostent_internal(VALUE v)
11371137
hostp = addr->ai_canonname;
11381138
}
11391139
else {
1140-
hostp = host_str(host, hbuf, sizeof(hbuf), NULL);
1140+
hostp = raddrinfo_host_str(host, hbuf, sizeof(hbuf), NULL);
11411141
}
11421142
rb_ary_push(ary, rb_str_new2(hostp));
11431143

ext/socket/rubysocket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ ssize_t rsock_recvmsg(int socket, struct msghdr *message, int flags);
414414
void rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p);
415415
#endif
416416

417-
char *host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr);
418-
char *port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr);
417+
char *raddrinfo_host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr);
418+
char *raddrinfo_port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr);
419419

420420
#ifndef FAST_FALLBACK_INIT_INETSOCK_IMPL
421421
# if !defined(HAVE_PTHREAD_CREATE) || !defined(HAVE_PTHREAD_DETACH) || defined(__MINGW32__) || defined(__MINGW64__)

0 commit comments

Comments
 (0)