1 [PATCH] Replace susv3 legacy function with modern equivalents
3 Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
5 nuttcp-6.1.2.c | 90 ++++++++++++++++++++++++++++-----------------------------
6 1 file changed, 45 insertions(+), 45 deletions(-)
8 Index: nuttcp-6.1.2/nuttcp-6.1.2.c
9 ===================================================================
10 --- nuttcp-6.1.2.orig/nuttcp-6.1.2.c
11 +++ nuttcp-6.1.2/nuttcp-6.1.2.c
12 @@ -1925,11 +1925,11 @@
13 if (udp && !haverateopt)
14 rate = DEFAULT_UDP_RATE;
16 - bzero((char *)&frominet, sizeof(frominet));
17 - bzero((char *)&clientaddr, sizeof(clientaddr));
18 + memset((char *)&frominet, 0, sizeof(frominet));
19 + memset((char *)&clientaddr, 0, sizeof(clientaddr));
22 - bzero((char *)&clientaddr6, sizeof(clientaddr6));
23 + memset((char *)&clientaddr6, 0, sizeof(clientaddr6));
30 while (stream_idx <= nstream) {
31 - bzero(&hints, sizeof(hints));
32 + memset(&hints, 0, sizeof(hints));
33 res[stream_idx] = NULL;
34 if (explicitaf) hints.ai_family = af;
35 if ((cp2 = strchr(cp1, '/'))) {
36 @@ -3013,12 +3013,12 @@
37 if ((stream_idx > 0) && skip_data)
40 - bzero((char *)&sinme[stream_idx], sizeof(sinme[stream_idx]));
41 - bzero((char *)&sinhim[stream_idx], sizeof(sinhim[stream_idx]));
42 + memset((char *)&sinme[stream_idx], 0, sizeof(sinme[stream_idx]));
43 + memset((char *)&sinhim[stream_idx], 0, sizeof(sinhim[stream_idx]));
46 - bzero((char *)&sinme6[stream_idx], sizeof(sinme6[stream_idx]));
47 - bzero((char *)&sinhim6[stream_idx], sizeof(sinhim6[stream_idx]));
48 + memset((char *)&sinme6[stream_idx], 0, sizeof(sinme6[stream_idx]));
49 + memset((char *)&sinhim6[stream_idx], 0, sizeof(sinhim6[stream_idx]));
52 if (((trans && !reverse) && (stream_idx > 0)) ||
53 @@ -3028,15 +3028,15 @@
56 sinhim[stream_idx].sin_family = af;
57 - bcopy((char *)&(((struct sockaddr_in *)res[stream_idx]->ai_addr)->sin_addr),
58 - (char *)&sinhim[stream_idx].sin_addr.s_addr,
59 + memcpy((char *)&sinhim[stream_idx].sin_addr.s_addr,
60 + (char *)&(((struct sockaddr_in *)res[stream_idx]->ai_addr)->sin_addr),
61 sizeof(sinhim[stream_idx].sin_addr.s_addr));
64 else if (af == AF_INET6) {
65 sinhim6[stream_idx].sin6_family = af;
66 - bcopy((char *)&(((struct sockaddr_in6 *)res[stream_idx]->ai_addr)->sin6_addr),
67 - (char *)&sinhim6[stream_idx].sin6_addr.s6_addr,
68 + memcpy((char *)&sinhim6[stream_idx].sin6_addr.s6_addr,
69 + (char *)&(((struct sockaddr_in6 *)res[stream_idx]->ai_addr)->sin6_addr),
70 sizeof(sinhim6[stream_idx].sin6_addr.s6_addr));
71 sinhim6[stream_idx].sin6_scope_id = ((struct sockaddr_in6 *)res[stream_idx]->ai_addr)->sin6_scope_id;
74 * to the multicast group
77 - bcopy((char *)&sinhim[1].sin_addr.s_addr,
78 - (char *)&save_sinhim.sin_addr.s_addr,
79 + memcpy((char *)&save_sinhim.sin_addr.s_addr,
80 + (char *)&sinhim[1].sin_addr.s_addr,
81 sizeof(struct in_addr));
82 if (!client && (irvers >= 50505)) {
83 struct sockaddr_in peer;
88 - bcopy((char *)&peer.sin_addr.s_addr,
89 - (char *)&sinhim[1].sin_addr.s_addr,
90 + memcpy((char *)&sinhim[1].sin_addr.s_addr,
91 + (char *)&peer.sin_addr.s_addr,
92 sizeof(struct in_addr));
99 - bcopy((char *)&me.sin_addr.s_addr,
100 - (char *)&sinhim[1].sin_addr.s_addr,
101 + memcpy((char *)&sinhim[1].sin_addr.s_addr,
102 + (char *)&me.sin_addr.s_addr,
103 sizeof(struct in_addr));
105 sinhim[1].sin_addr.s_addr &=
106 @@ -4197,13 +4197,13 @@
110 - bcopy((char *)&me.sin_addr.s_addr,
111 - (char *)&mc_group.imr_multiaddr.s_addr,
112 + memcpy((char *)&mc_group.imr_multiaddr.s_addr,
113 + (char *)&me.sin_addr.s_addr,
114 sizeof(struct in_addr));
117 - bcopy((char *)&peer.sin_addr.s_addr,
118 - (char *)&mc_group.imr_multiaddr.s_addr,
119 + memcpy((char *)&mc_group.imr_multiaddr.s_addr,
120 + (char *)&peer.sin_addr.s_addr,
121 sizeof(struct in_addr));
123 mc_group.imr_multiaddr.s_addr &= htonl(0xFFFFFF);
124 @@ -4330,12 +4330,12 @@
128 - bcopy((char *)&sinhim[1].sin_addr.s_addr,
129 - (char *)&save_mc.sin_addr.s_addr,
130 - sizeof(struct in_addr));
131 - bcopy((char *)&save_sinhim.sin_addr.s_addr,
132 + memcpy((char *)&save_mc.sin_addr.s_addr,
133 (char *)&sinhim[1].sin_addr.s_addr,
134 sizeof(struct in_addr));
135 + memcpy((char *)&sinhim[1].sin_addr.s_addr,
136 + (char *)&save_sinhim.sin_addr.s_addr,
137 + sizeof(struct in_addr));
139 (void)Nwrite( fd[stream_idx + 1], buf, 4 ); /* rcvr start */
141 @@ -4344,8 +4344,8 @@
142 (void)Nwrite( fd[stream_idx + 1], buf, 4 ); /* rcvr start */
145 - bcopy((char *)&save_mc.sin_addr.s_addr,
146 - (char *)&sinhim[1].sin_addr.s_addr,
147 + memcpy((char *)&sinhim[1].sin_addr.s_addr,
148 + (char *)&save_mc.sin_addr.s_addr,
149 sizeof(struct in_addr));
152 @@ -4361,7 +4361,7 @@
156 - bcopy(&nbytes, buf + 24, 8);
157 + memcpy(buf + 24, &nbytes, 8);
158 if (!udp && interval && !(format & NORETRANS) &&
159 ((retransinfo == 1) ||
160 ((retransinfo >= 2) &&
161 @@ -4372,13 +4372,13 @@
162 tmp = 0x5254524Eu; /* "RTRN" */
164 tmp = 0x48525452u; /* "HRTR" */
165 - bcopy(&nretrans, buf + 24, 4);
166 - bcopy(&tmp, buf + 28, 4);
167 + memcpy(buf + 24, &nretrans, 4);
168 + memcpy(buf + 28, &tmp, 4);
173 - bzero(buf + 24, 8);
174 + memset(buf + 24, 0, 8);
178 @@ -4423,12 +4423,12 @@
182 - bcopy(&nbytes, buf + 24, 8);
183 + memcpy(buf + 24, &nbytes, 8);
185 nretrans = get_retrans(
187 nretrans -= iretrans;
188 - bcopy(&nretrans, buf + 24, 4);
189 + memcpy(buf + 24, &nretrans, 4);
192 stream_idx = stream_idx % nstream;
193 @@ -4523,8 +4523,8 @@
197 - bcopy((char *)&save_sinhim.sin_addr.s_addr,
198 - (char *)&sinhim[1].sin_addr.s_addr,
199 + memcpy((char *)&sinhim[1].sin_addr.s_addr,
200 + (char *)&save_sinhim.sin_addr.s_addr,
201 sizeof(struct in_addr));
203 (void)Nwrite( fd[stream_idx + 1], buf, 4 ); /* rcvr end */
204 @@ -4532,7 +4532,7 @@
208 - bzero(buf + 24, 8);
209 + memset(buf + 24, 0, 8);
213 @@ -4584,7 +4584,7 @@
214 * goes off right here */
217 - bcopy(buf + 24, &ntbytesc,
218 + memcpy(&ntbytesc, buf + 24,
221 if (ntbytesc > 0x100000000ull)
222 @@ -4598,7 +4598,7 @@
226 - bcopy(buf + 24, &ntbytesc,
227 + memcpy(&ntbytesc, buf + 24,
230 cp1 = (char *)&ntbytesc;
231 @@ -4627,8 +4627,8 @@
235 - bcopy(buf + 24, &nretrans, 4);
236 - bcopy(buf + 28, &tmp, 4);
237 + memcpy(&nretrans, buf + 24, 4);
238 + memcpy(&tmp, buf + 28, 4);
239 if (tmp == 0x5254524Eu) {
242 @@ -4661,7 +4661,7 @@
246 - bcopy(buf + 24, &nretrans,
247 + memcpy(&nretrans, buf + 24,
250 cp1 = (char *)&nretrans;
251 @@ -5327,10 +5327,10 @@
252 itimer.it_interval.tv_usec = 0;
253 setitimer(ITIMER_REAL, &itimer, 0);
254 signal(SIGALRM, SIG_DFL);
255 - bzero((char *)&frominet, sizeof(frominet));
256 - bzero((char *)&clientaddr, sizeof(clientaddr));
257 + memset((char *)&frominet, 0, sizeof(frominet));
258 + memset((char *)&clientaddr, 0, sizeof(clientaddr));
260 - bzero((char *)&clientaddr6, sizeof(clientaddr));
261 + memset((char *)&clientaddr6, 0, sizeof(clientaddr));