From b5afd1d59648565e1fcc32518df9faf96c1667df Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sun, 11 Nov 2018 01:07:31 +1100 Subject: [PATCH] Replace last uses of bcopy() with memcpy() memcpy() / memmove() are standard everywhere, this lets us remove the configure script checking around bcopy() which helps building on Haiku OS. --- Changelog | 2 ++ dll/cavlink/cavlink.c | 2 +- dll/nap/nap.c | 4 ++-- source/misc.c | 36 +++++++++++++++--------------------- source/network.c | 5 ++--- 5 files changed, 22 insertions(+), 27 deletions(-) diff --git a/Changelog b/Changelog index 9be9a69..440eef9 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2.2] +* Replace last uses of bcopy() with memcpy(). (caf) + * Fix /HISTORY *pattern* and /HISTORY -CLEAR. (caf) * Fix /SET TAB OFF. (caf) diff --git a/dll/cavlink/cavlink.c b/dll/cavlink/cavlink.c index 4af7871..3390247 100644 --- a/dll/cavlink/cavlink.c +++ b/dll/cavlink/cavlink.c @@ -1111,7 +1111,7 @@ SocketList *cavlink_connect(char *host, u_short port) set_lastlog_msg_level(lastlog_level); return NULL; } - bcopy(hp->h_addr, (char *)&address, sizeof(address)); + memcpy(&address, hp->h_addr, sizeof(address)); } cav_socket = connect_by_number(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 1); if (cav_socket < 0) diff --git a/dll/nap/nap.c b/dll/nap/nap.c index 8dbbb72..4fc0fb7 100644 --- a/dll/nap/nap.c +++ b/dll/nap/nap.c @@ -1129,7 +1129,7 @@ SocketList *naplink_connect(char *host, u_short port) set_lastlog_msg_level(lastlog_level); return NULL; } - bcopy(hp->h_addr, (char *)&address, sizeof(address)); + memcpy(&address, hp->h_addr, sizeof(address)); } nap_socket = connectbynumber(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 0); if (nap_socket < 0) @@ -1233,7 +1233,7 @@ void naplink_getserver(char *host, u_short port, int create) set_lastlog_msg_level(lastlog_level); return; } - bcopy(hp->h_addr, (char *)&address, sizeof(address)); + memcpy(&address, hp->h_addr, sizeof(address)); } nap_socket = connectbynumber(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 1); if (nap_socket < 0) diff --git a/source/misc.c b/source/misc.c index 172f758..827404e 100644 --- a/source/misc.c +++ b/source/misc.c @@ -1778,7 +1778,7 @@ struct in_addr ip; { if (rptr->re_he.h_addr_list[0].s_addr) { - bcopy(&rptr->re_he.h_addr_list[0], (char *)&ip, sizeof(ip)); + memcpy(&ip, &rptr->re_he.h_addr_list[0], sizeof ip); nick->ip = m_strdup(inet_ntoa(ip)); #ifdef WANT_USERLIST check_auto(chan->channel, nick, chan); @@ -1812,7 +1812,7 @@ struct in_addr ip; sprintf(buffer, "%s ", h); for (i = 0; rptr->re_he.h_addr_list[i].s_addr; i++) { - bcopy(&rptr->re_he.h_addr_list[i], (char *)&ip, sizeof(ip)); + memcpy(&ip, &rptr->re_he.h_addr_list[i], sizeof ip); BX_strpcat(buffer, "%s ", inet_ntoa(ip)); if (strlen(buffer) > 490) break; @@ -1830,7 +1830,7 @@ struct in_addr ip; bitchsay("%s is %s (%s)", h, rptr->re_he.h_name ? rptr->re_he.h_name:"invalid hostname", (char *)inet_ntoa(rptr->re_he.h_addr_list[0])); for (i = 0; rptr->re_he.h_addr_list[i].s_addr; i++) { - bcopy(&rptr->re_he.h_addr_list[i], (char *)&ip, sizeof(ip)); + memcpy(&ip, &rptr->re_he.h_addr_list[i], sizeof ip); BX_strpcat(buffer, "[%s] ", inet_ntoa(ip)); if (strlen(buffer) > 490) break; @@ -2276,7 +2276,7 @@ long ar_timeout(time_t now, char *info, int size, void (*func)(struct reslist *) { ar_reinfo.re_timeouts++; if (info && rptr->re_rinfo.ri_ptr) - bcopy(rptr->re_rinfo.ri_ptr, info, + memcpy(info, rptr->re_rinfo.ri_ptr, MIN(rptr->re_rinfo.ri_size, size)); if (rptr->func) (*rptr->func)(rptr); @@ -2431,24 +2431,21 @@ static int ar_query_name(char *name, int class, int type, struct reslist *rptr) */ int ar_gethostbyname(char *name, char *info, int size, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command) { - char host[HOSTLEN+1]; - struct resinfo resi; - register struct resinfo *rp = &resi; + char host[HOSTLEN+1]; + struct resinfo resi = { 0 }; if (size && info) { - rp->ri_ptr = (char *)new_malloc(size+1); + resi.ri_ptr = new_malloc(size + 1); if (*info) - bcopy(info, rp->ri_ptr, size); - rp->ri_size = size; + memcpy(resi.ri_ptr, info, size); + resi.ri_size = size; } - else - memset((char *)rp, 0, sizeof(resi)); ar_reinfo.re_na_look++; (void)strncpy(host, name, 64); host[64] = '\0'; - return (do_query_name(rp, host, NULL, nick, user, h, chan, server, func, command)); + return do_query_name(&resi, host, NULL, nick, user, h, chan, server, func, command); } static int do_query_name(struct resinfo *resi, char *name, register struct reslist *rptr, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command) @@ -2496,20 +2493,17 @@ static int do_query_name(struct resinfo *resi, char *name, register struct resli */ int ar_gethostbyaddr(char *addr, char *info, int size, char *nick, char *user, char *h, char *chan, int server, void (*func)(), char *command) { - struct resinfo resi; - register struct resinfo *rp = &resi; + struct resinfo resi = { 0 }; if (size && info) { - rp->ri_ptr = (char *)new_malloc(size+1); + resi.ri_ptr = new_malloc(size + 1); if (*info) - bcopy(info, rp->ri_ptr, size); - rp->ri_size = size; + memcpy(resi.ri_ptr, info, size); + resi.ri_size = size; } - else - memset((char *)rp, 0, sizeof(resi)); ar_reinfo.re_nu_look++; - return (do_query_number(rp, addr, NULL, nick, user, h, chan, server, func, command)); + return do_query_number(&resi, addr, NULL, nick, user, h, chan, server, func, command); } /* diff --git a/source/network.c b/source/network.c index 200a4ef..ccf9877 100644 --- a/source/network.c +++ b/source/network.c @@ -322,7 +322,7 @@ int handle_socks(int fd, struct sockaddr_in addr, char *host, int portnum) bitchsay("Unable to resolve SOCKS proxy host address: %s", host); return -1; } - bcopy(hp->h_addr, (char *)&proxy.sin_addr, hp->h_length); + memcpy(&proxy.sin_addr, hp->h_addr, hp->h_length); proxy.sin_family = AF_INET; proxy.sin_port = htons(portnum); alarm(get_int_var(CONNECT_TIMEOUT_VAR)); @@ -600,8 +600,7 @@ int BX_connect_by_number(char *hostn, unsigned short *portnum, int service, int if ((hp = gethostbyname(hostn)) != NULL) { memset(&server, 0, sizeof(server)); - bcopy(hp->h_addr, (char *) &server.sf_addr, - hp->h_length); + memcpy(&server.sf_addr, hp->h_addr, hp->h_length); server.sf_family = hp->h_addrtype; } else