Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Put back NULL tests for allocation failures.
details: https://anonhg.NetBSD.org/src/rev/b151aca82473
branches: trunk
changeset: 341466:b151aca82473
user: christos <christos%NetBSD.org@localhost>
date: Sat Nov 07 16:58:24 2015 +0000
description:
Put back NULL tests for allocation failures.
diffstat:
include/rpc/svc.h | 6 +++---
lib/libc/rpc/svc_fdset.c | 30 +++++++++++++++++++++++++-----
2 files changed, 28 insertions(+), 8 deletions(-)
diffs (122 lines):
diff -r e3c3546d3e1b -r b151aca82473 include/rpc/svc.h
--- a/include/rpc/svc.h Sat Nov 07 16:53:59 2015 +0000
+++ b/include/rpc/svc.h Sat Nov 07 16:58:24 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svc.h,v 1.27 2015/11/06 19:42:57 christos Exp $ */
+/* $NetBSD: svc.h,v 1.28 2015/11/07 16:58:24 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -316,8 +316,8 @@
extern void svc_fdset_zero(void);
extern int svc_fdset_isset(int);
-extern void svc_fdset_clr(int);
-extern void svc_fdset_set(int);
+extern int svc_fdset_clr(int);
+extern int svc_fdset_set(int);
extern fd_set *svc_fdset_get(void);
extern int svc_fdset_getsize(int);
diff -r e3c3546d3e1b -r b151aca82473 lib/libc/rpc/svc_fdset.c
--- a/lib/libc/rpc/svc_fdset.c Sat Nov 07 16:53:59 2015 +0000
+++ b/lib/libc/rpc/svc_fdset.c Sat Nov 07 16:58:24 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svc_fdset.c,v 1.6 2015/11/07 03:06:32 christos Exp $ */
+/* $NetBSD: svc_fdset.c,v 1.7 2015/11/07 16:58:24 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: svc_fdset.c,v 1.6 2015/11/07 03:06:32 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.7 2015/11/07 16:58:24 christos Exp $");
#include "reentrant.h"
@@ -219,11 +219,14 @@
fds->fdmax = -1;
}
-void
+int
svc_fdset_set(int fd)
{
struct svc_fdset *fds = svc_fdset_alloc(fd);
+ if (fds == NULL)
+ return -1;
+
FD_SET(fd, fds->fdset);
if (fd > fds->fdmax)
fds->fdmax = fd;
@@ -231,6 +234,7 @@
DPRINTF_FDSET(fds, "%d", fd);
svc_fdset_sanitize(fds);
+ return 0;
}
int
@@ -238,20 +242,27 @@
{
struct svc_fdset *fds = svc_fdset_alloc(fd);
+ if (fds == NULL)
+ return -1;
+
DPRINTF_FDSET(fds, "%d", fd);
- return FD_ISSET(fd, fds->fdset);
+ return FD_ISSET(fd, fds->fdset) != 0;
}
-void
+int
svc_fdset_clr(int fd)
{
struct svc_fdset *fds = svc_fdset_alloc(fd);
+ if (fds == NULL)
+ return -1;
+
FD_CLR(fd, fds->fdset);
DPRINTF_FDSET(fds, "%d", fd);
svc_fdset_sanitize(fds);
+ return 0;
}
fd_set *
@@ -271,6 +282,9 @@
{
struct svc_fdset *fds = svc_fdset_alloc(0);
+ if (fds == NULL)
+ return NULL;
+
DPRINTF_FDSET(fds, "get");
svc_fdset_sanitize(fds);
return fds->fdset;
@@ -281,6 +295,9 @@
{
struct svc_fdset *fds = svc_fdset_alloc(0);
+ if (fds == NULL)
+ return NULL;
+
DPRINTF_FDSET(fds, "getmax");
svc_fdset_sanitize(fds);
return &fds->fdmax;
@@ -291,6 +308,9 @@
{
struct svc_fdset *fds = svc_fdset_alloc(fd);
+ if (fds == NULL)
+ return -1;
+
DPRINTF_FDSET(fds, "getsize");
return fds->fdsize;
}
Home |
Main Index |
Thread Index |
Old Index