Sat Nov 7 16:58:24 2015 UTC ()
Put back NULL tests for allocation failures.


(christos)
diff -r1.27 -r1.28 src/include/rpc/svc.h
diff -r1.6 -r1.7 src/lib/libc/rpc/svc_fdset.c

cvs diff -r1.27 -r1.28 src/include/rpc/svc.h (expand / switch to unified diff)

--- src/include/rpc/svc.h 2015/11/06 19:42:57 1.27
+++ src/include/rpc/svc.h 2015/11/07 16:58:24 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: svc.h,v 1.27 2015/11/06 19:42:57 christos Exp $ */ 1/* $NetBSD: svc.h,v 1.28 2015/11/07 16:58:24 christos Exp $ */
2 2
3/* 3/*
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape 5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users 6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized 7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or 8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user. 9 * program developed by the user.
10 * 10 *
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 * 14 *
@@ -306,28 +306,28 @@ extern fd_set svc_fdset; @@ -306,28 +306,28 @@ extern fd_set svc_fdset;
306 */ 306 */
307__BEGIN_DECLS 307__BEGIN_DECLS
308extern void rpctest_service(void); 308extern void rpctest_service(void);
309__END_DECLS 309__END_DECLS
310 310
311__BEGIN_DECLS 311__BEGIN_DECLS
312 312
313#define SVC_FDSET_MT 1 313#define SVC_FDSET_MT 1
314extern void svc_fdset_init(int); 314extern void svc_fdset_init(int);
315extern fd_set *svc_fdset_copy(const fd_set *); 315extern fd_set *svc_fdset_copy(const fd_set *);
316 316
317extern void svc_fdset_zero(void); 317extern void svc_fdset_zero(void);
318extern int svc_fdset_isset(int); 318extern int svc_fdset_isset(int);
319extern void svc_fdset_clr(int); 319extern int svc_fdset_clr(int);
320extern void svc_fdset_set(int); 320extern int svc_fdset_set(int);
321 321
322extern fd_set *svc_fdset_get(void); 322extern fd_set *svc_fdset_get(void);
323extern int svc_fdset_getsize(int); 323extern int svc_fdset_getsize(int);
324extern int *svc_fdset_getmax(void); 324extern int *svc_fdset_getmax(void);
325 325
326extern void svc_getreq (int); 326extern void svc_getreq (int);
327extern void svc_getreqset (fd_set *); 327extern void svc_getreqset (fd_set *);
328extern void svc_getreqset2 (fd_set *, int); 328extern void svc_getreqset2 (fd_set *, int);
329extern void svc_getreq_common (int); 329extern void svc_getreq_common (int);
330struct pollfd; 330struct pollfd;
331extern void svc_getreq_poll(struct pollfd *, int); 331extern void svc_getreq_poll(struct pollfd *, int);
332 332
333extern void svc_run (void); 333extern void svc_run (void);

cvs diff -r1.6 -r1.7 src/lib/libc/rpc/svc_fdset.c (expand / switch to unified diff)

--- src/lib/libc/rpc/svc_fdset.c 2015/11/07 03:06:32 1.6
+++ src/lib/libc/rpc/svc_fdset.c 2015/11/07 16:58:24 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: svc_fdset.c,v 1.6 2015/11/07 03:06:32 christos Exp $ */ 1/* $NetBSD: svc_fdset.c,v 1.7 2015/11/07 16:58:24 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 The NetBSD Foundation, Inc. 4 * Copyright (c) 2015 The NetBSD Foundation, Inc.
5 * All rights resefdsed. 5 * All rights resefdsed.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas. 8 * by Christos Zoulas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__RCSID("$NetBSD: svc_fdset.c,v 1.6 2015/11/07 03:06:32 christos Exp $"); 33__RCSID("$NetBSD: svc_fdset.c,v 1.7 2015/11/07 16:58:24 christos Exp $");
34 34
35 35
36#include "reentrant.h" 36#include "reentrant.h"
37 37
38#include <sys/fd_set.h> 38#include <sys/fd_set.h>
39 39
40#include <rpc/rpc.h> 40#include <rpc/rpc.h>
41 41
42#ifdef FDSET_DEBUG 42#ifdef FDSET_DEBUG
43#include <stdio.h> 43#include <stdio.h>
44#include <stdarg.h> 44#include <stdarg.h>
45#include <unistd.h> 45#include <unistd.h>
46#include <lwp.h> 46#include <lwp.h>
@@ -209,88 +209,108 @@ svc_fdset_init(int flags) @@ -209,88 +209,108 @@ svc_fdset_init(int flags)
209 if ((flags & SVC_FDSET_MT) && fdsetkey == -2) 209 if ((flags & SVC_FDSET_MT) && fdsetkey == -2)
210 fdsetkey = -1; 210 fdsetkey = -1;
211} 211}
212 212
213void 213void
214svc_fdset_zero(void) 214svc_fdset_zero(void)
215{ 215{
216 DPRINTF("zero"); 216 DPRINTF("zero");
217 struct svc_fdset *fds = svc_fdset_alloc(0); 217 struct svc_fdset *fds = svc_fdset_alloc(0);
218 memset(fds->fdset, 0, fds->fdsize); 218 memset(fds->fdset, 0, fds->fdsize);
219 fds->fdmax = -1; 219 fds->fdmax = -1;
220} 220}
221 221
222void 222int
223svc_fdset_set(int fd) 223svc_fdset_set(int fd)
224{ 224{
225 struct svc_fdset *fds = svc_fdset_alloc(fd); 225 struct svc_fdset *fds = svc_fdset_alloc(fd);
226 226
 227 if (fds == NULL)
 228 return -1;
 229
227 FD_SET(fd, fds->fdset); 230 FD_SET(fd, fds->fdset);
228 if (fd > fds->fdmax) 231 if (fd > fds->fdmax)
229 fds->fdmax = fd; 232 fds->fdmax = fd;
230 233
231 DPRINTF_FDSET(fds, "%d", fd); 234 DPRINTF_FDSET(fds, "%d", fd);
232 235
233 svc_fdset_sanitize(fds); 236 svc_fdset_sanitize(fds);
 237 return 0;
234} 238}
235 239
236int 240int
237svc_fdset_isset(int fd) 241svc_fdset_isset(int fd)
238{ 242{
239 struct svc_fdset *fds = svc_fdset_alloc(fd); 243 struct svc_fdset *fds = svc_fdset_alloc(fd);
240 244
 245 if (fds == NULL)
 246 return -1;
 247
241 DPRINTF_FDSET(fds, "%d", fd); 248 DPRINTF_FDSET(fds, "%d", fd);
242 249
243 return FD_ISSET(fd, fds->fdset); 250 return FD_ISSET(fd, fds->fdset) != 0;
244} 251}
245 252
246void 253int
247svc_fdset_clr(int fd) 254svc_fdset_clr(int fd)
248{ 255{
249 struct svc_fdset *fds = svc_fdset_alloc(fd); 256 struct svc_fdset *fds = svc_fdset_alloc(fd);
250 257
 258 if (fds == NULL)
 259 return -1;
 260
251 FD_CLR(fd, fds->fdset); 261 FD_CLR(fd, fds->fdset);
252 DPRINTF_FDSET(fds, "%d", fd); 262 DPRINTF_FDSET(fds, "%d", fd);
253 263
254 svc_fdset_sanitize(fds); 264 svc_fdset_sanitize(fds);
 265 return 0;
255} 266}
256 267
257fd_set * 268fd_set *
258svc_fdset_copy(const fd_set *orig) 269svc_fdset_copy(const fd_set *orig)
259{ 270{
260 int size = svc_fdset_getsize(0); 271 int size = svc_fdset_getsize(0);
261 fd_set *copy = calloc(1, __NFD_BYTES(size)); 272 fd_set *copy = calloc(1, __NFD_BYTES(size));
262 if (copy == NULL) 273 if (copy == NULL)
263 return NULL; 274 return NULL;
264 if (orig) 275 if (orig)
265 memcpy(copy, orig, __NFD_BYTES(size)); 276 memcpy(copy, orig, __NFD_BYTES(size));
266 return copy; 277 return copy;
267} 278}
268 279
269fd_set * 280fd_set *
270svc_fdset_get(void) 281svc_fdset_get(void)
271{ 282{
272 struct svc_fdset *fds = svc_fdset_alloc(0); 283 struct svc_fdset *fds = svc_fdset_alloc(0);
273 284
 285 if (fds == NULL)
 286 return NULL;
 287
274 DPRINTF_FDSET(fds, "get"); 288 DPRINTF_FDSET(fds, "get");
275 svc_fdset_sanitize(fds); 289 svc_fdset_sanitize(fds);
276 return fds->fdset; 290 return fds->fdset;
277} 291}
278 292
279int * 293int *
280svc_fdset_getmax(void) 294svc_fdset_getmax(void)
281{ 295{
282 struct svc_fdset *fds = svc_fdset_alloc(0); 296 struct svc_fdset *fds = svc_fdset_alloc(0);
283 297
 298 if (fds == NULL)
 299 return NULL;
 300
284 DPRINTF_FDSET(fds, "getmax"); 301 DPRINTF_FDSET(fds, "getmax");
285 svc_fdset_sanitize(fds); 302 svc_fdset_sanitize(fds);
286 return &fds->fdmax; 303 return &fds->fdmax;
287} 304}
288 305
289int 306int
290svc_fdset_getsize(int fd) 307svc_fdset_getsize(int fd)
291{ 308{
292 struct svc_fdset *fds = svc_fdset_alloc(fd); 309 struct svc_fdset *fds = svc_fdset_alloc(fd);
293 310
 311 if (fds == NULL)
 312 return -1;
 313
294 DPRINTF_FDSET(fds, "getsize"); 314 DPRINTF_FDSET(fds, "getsize");
295 return fds->fdsize; 315 return fds->fdsize;
296} 316}