kumquat-buildroot/package/nuttcp/nuttcp-6.1.2-susv3-legacy.patch

265 lines
8.4 KiB
Diff
Raw Normal View History

[PATCH] Replace susv3 legacy function with modern equivalents
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
nuttcp-6.1.2.c | 90 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 45 insertions(+), 45 deletions(-)
Index: nuttcp-6.1.2/nuttcp-6.1.2.c
===================================================================
--- nuttcp-6.1.2.orig/nuttcp-6.1.2.c
+++ nuttcp-6.1.2/nuttcp-6.1.2.c
@@ -1925,11 +1925,11 @@
if (udp && !haverateopt)
rate = DEFAULT_UDP_RATE;
- bzero((char *)&frominet, sizeof(frominet));
- bzero((char *)&clientaddr, sizeof(clientaddr));
+ memset((char *)&frominet, 0, sizeof(frominet));
+ memset((char *)&clientaddr, 0, sizeof(clientaddr));
#ifdef AF_INET6
- bzero((char *)&clientaddr6, sizeof(clientaddr6));
+ memset((char *)&clientaddr6, 0, sizeof(clientaddr6));
clientscope6 = 0;
#endif
@@ -1985,7 +1985,7 @@
}
while (stream_idx <= nstream) {
- bzero(&hints, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
res[stream_idx] = NULL;
if (explicitaf) hints.ai_family = af;
if ((cp2 = strchr(cp1, '/'))) {
@@ -3013,12 +3013,12 @@
if ((stream_idx > 0) && skip_data)
break;
- bzero((char *)&sinme[stream_idx], sizeof(sinme[stream_idx]));
- bzero((char *)&sinhim[stream_idx], sizeof(sinhim[stream_idx]));
+ memset((char *)&sinme[stream_idx], 0, sizeof(sinme[stream_idx]));
+ memset((char *)&sinhim[stream_idx], 0, sizeof(sinhim[stream_idx]));
#ifdef AF_INET6
- bzero((char *)&sinme6[stream_idx], sizeof(sinme6[stream_idx]));
- bzero((char *)&sinhim6[stream_idx], sizeof(sinhim6[stream_idx]));
+ memset((char *)&sinme6[stream_idx], 0, sizeof(sinme6[stream_idx]));
+ memset((char *)&sinhim6[stream_idx], 0, sizeof(sinhim6[stream_idx]));
#endif
if (((trans && !reverse) && (stream_idx > 0)) ||
@@ -3028,15 +3028,15 @@
if (client) {
if (af == AF_INET) {
sinhim[stream_idx].sin_family = af;
- bcopy((char *)&(((struct sockaddr_in *)res[stream_idx]->ai_addr)->sin_addr),
- (char *)&sinhim[stream_idx].sin_addr.s_addr,
+ memcpy((char *)&sinhim[stream_idx].sin_addr.s_addr,
+ (char *)&(((struct sockaddr_in *)res[stream_idx]->ai_addr)->sin_addr),
sizeof(sinhim[stream_idx].sin_addr.s_addr));
}
#ifdef AF_INET6
else if (af == AF_INET6) {
sinhim6[stream_idx].sin6_family = af;
- bcopy((char *)&(((struct sockaddr_in6 *)res[stream_idx]->ai_addr)->sin6_addr),
- (char *)&sinhim6[stream_idx].sin6_addr.s6_addr,
+ memcpy((char *)&sinhim6[stream_idx].sin6_addr.s6_addr,
+ (char *)&(((struct sockaddr_in6 *)res[stream_idx]->ai_addr)->sin6_addr),
sizeof(sinhim6[stream_idx].sin6_addr.s6_addr));
sinhim6[stream_idx].sin6_scope_id = ((struct sockaddr_in6 *)res[stream_idx]->ai_addr)->sin6_scope_id;
}
@@ -3113,8 +3113,8 @@
* to the multicast group
*/
if (af == AF_INET) {
- bcopy((char *)&sinhim[1].sin_addr.s_addr,
- (char *)&save_sinhim.sin_addr.s_addr,
+ memcpy((char *)&save_sinhim.sin_addr.s_addr,
+ (char *)&sinhim[1].sin_addr.s_addr,
sizeof(struct in_addr));
if (!client && (irvers >= 50505)) {
struct sockaddr_in peer;
@@ -3124,8 +3124,8 @@
&peerlen) < 0) {
err("getpeername");
}
- bcopy((char *)&peer.sin_addr.s_addr,
- (char *)&sinhim[1].sin_addr.s_addr,
+ memcpy((char *)&sinhim[1].sin_addr.s_addr,
+ (char *)&peer.sin_addr.s_addr,
sizeof(struct in_addr));
}
else {
@@ -3136,8 +3136,8 @@
&melen) < 0) {
err("getsockname");
}
- bcopy((char *)&me.sin_addr.s_addr,
- (char *)&sinhim[1].sin_addr.s_addr,
+ memcpy((char *)&sinhim[1].sin_addr.s_addr,
+ (char *)&me.sin_addr.s_addr,
sizeof(struct in_addr));
}
sinhim[1].sin_addr.s_addr &=
@@ -4197,13 +4197,13 @@
&melen) < 0) {
err("getsockname");
}
- bcopy((char *)&me.sin_addr.s_addr,
- (char *)&mc_group.imr_multiaddr.s_addr,
+ memcpy((char *)&mc_group.imr_multiaddr.s_addr,
+ (char *)&me.sin_addr.s_addr,
sizeof(struct in_addr));
}
else {
- bcopy((char *)&peer.sin_addr.s_addr,
- (char *)&mc_group.imr_multiaddr.s_addr,
+ memcpy((char *)&mc_group.imr_multiaddr.s_addr,
+ (char *)&peer.sin_addr.s_addr,
sizeof(struct in_addr));
}
mc_group.imr_multiaddr.s_addr &= htonl(0xFFFFFF);
@@ -4330,12 +4330,12 @@
if(udp) {
strcpy(buf, "BOD0");
if (multicast) {
- bcopy((char *)&sinhim[1].sin_addr.s_addr,
- (char *)&save_mc.sin_addr.s_addr,
- sizeof(struct in_addr));
- bcopy((char *)&save_sinhim.sin_addr.s_addr,
+ memcpy((char *)&save_mc.sin_addr.s_addr,
(char *)&sinhim[1].sin_addr.s_addr,
sizeof(struct in_addr));
+ memcpy((char *)&sinhim[1].sin_addr.s_addr,
+ (char *)&save_sinhim.sin_addr.s_addr,
+ sizeof(struct in_addr));
}
(void)Nwrite( fd[stream_idx + 1], buf, 4 ); /* rcvr start */
if (two_bod) {
@@ -4344,8 +4344,8 @@
(void)Nwrite( fd[stream_idx + 1], buf, 4 ); /* rcvr start */
}
if (multicast) {
- bcopy((char *)&save_mc.sin_addr.s_addr,
- (char *)&sinhim[1].sin_addr.s_addr,
+ memcpy((char *)&sinhim[1].sin_addr.s_addr,
+ (char *)&save_mc.sin_addr.s_addr,
sizeof(struct in_addr));
}
if (timeout)
@@ -4361,7 +4361,7 @@
fflush(stdout);
}
if (udplossinfo)
- bcopy(&nbytes, buf + 24, 8);
+ memcpy(buf + 24, &nbytes, 8);
if (!udp && interval && !(format & NORETRANS) &&
((retransinfo == 1) ||
((retransinfo >= 2) &&
@@ -4372,13 +4372,13 @@
tmp = 0x5254524Eu; /* "RTRN" */
else
tmp = 0x48525452u; /* "HRTR" */
- bcopy(&nretrans, buf + 24, 4);
- bcopy(&tmp, buf + 28, 4);
+ memcpy(buf + 24, &nretrans, 4);
+ memcpy(buf + 28, &tmp, 4);
}
else {
send_retrans = 0;
if (!udp)
- bzero(buf + 24, 8);
+ memset(buf + 24, 0, 8);
}
if (nbuf == INT_MAX)
nbuf = ULLONG_MAX;
@@ -4423,12 +4423,12 @@
nbytes += buflen;
cnt = 0;
if (udplossinfo)
- bcopy(&nbytes, buf + 24, 8);
+ memcpy(buf + 24, &nbytes, 8);
if (send_retrans) {
nretrans = get_retrans(
fd[stream_idx + 1]);
nretrans -= iretrans;
- bcopy(&nretrans, buf + 24, 4);
+ memcpy(buf + 24, &nretrans, 4);
}
stream_idx++;
stream_idx = stream_idx % nstream;
@@ -4523,8 +4523,8 @@
nbytes += cnt;
if(udp) {
if (multicast)
- bcopy((char *)&save_sinhim.sin_addr.s_addr,
- (char *)&sinhim[1].sin_addr.s_addr,
+ memcpy((char *)&sinhim[1].sin_addr.s_addr,
+ (char *)&save_sinhim.sin_addr.s_addr,
sizeof(struct in_addr));
strcpy(buf, "EOD0");
(void)Nwrite( fd[stream_idx + 1], buf, 4 ); /* rcvr end */
@@ -4532,7 +4532,7 @@
} else {
first_read = 1;
need_swap = 0;
- bzero(buf + 24, 8);
+ memset(buf + 24, 0, 8);
if (udp) {
ntbytesc = 0;
got_eod0 = 0;
@@ -4584,7 +4584,7 @@
* goes off right here */
if (udplossinfo) {
if (first_read) {
- bcopy(buf + 24, &ntbytesc,
+ memcpy(&ntbytesc, buf + 24,
8);
first_read = 0;
if (ntbytesc > 0x100000000ull)
@@ -4598,7 +4598,7 @@
}
}
if (!need_swap)
- bcopy(buf + 24, &ntbytesc,
+ memcpy(&ntbytesc, buf + 24,
8);
else {
cp1 = (char *)&ntbytesc;
@@ -4627,8 +4627,8 @@
uint32_t tmp;
first_read = 0;
- bcopy(buf + 24, &nretrans, 4);
- bcopy(buf + 28, &tmp, 4);
+ memcpy(&nretrans, buf + 24, 4);
+ memcpy(&tmp, buf + 28, 4);
if (tmp == 0x5254524Eu) {
/* "RTRN" */
retransinfo = 1;
@@ -4661,7 +4661,7 @@
}
if (read_retrans) {
if (!need_swap)
- bcopy(buf + 24, &nretrans,
+ memcpy(&nretrans, buf + 24,
4);
else {
cp1 = (char *)&nretrans;
@@ -5327,10 +5327,10 @@
itimer.it_interval.tv_usec = 0;
setitimer(ITIMER_REAL, &itimer, 0);
signal(SIGALRM, SIG_DFL);
- bzero((char *)&frominet, sizeof(frominet));
- bzero((char *)&clientaddr, sizeof(clientaddr));
+ memset((char *)&frominet, 0, sizeof(frominet));
+ memset((char *)&clientaddr, 0, sizeof(clientaddr));
#ifdef AF_INET6
- bzero((char *)&clientaddr6, sizeof(clientaddr));
+ memset((char *)&clientaddr6, 0, sizeof(clientaddr));
clientscope6 = 0;
#endif
cput = 0.000001;