summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBret Lambert <blambert@cvs.openbsd.org>2009-01-13 13:36:13 +0000
committerBret Lambert <blambert@cvs.openbsd.org>2009-01-13 13:36:13 +0000
commit9c7e0fea63c2ab02df4f18e020bf1813e4896cb3 (patch)
tree495efbae376258dfb35f681c779b2e1bde5f9bc8
parent74404c814527f9b867a0d3c8318ba30d5c4c5704 (diff)
Change sbreserve() to return 0 on success, 1 on failure, as god intended.
This sort of breaking with traditional and expected behavior annoys me. "yes!" henning@
-rw-r--r--sys/kern/uipc_socket.c6
-rw-r--r--sys/kern/uipc_socket2.c10
2 files changed, 8 insertions, 8 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index dd1ad2ddce8..a480f790483 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.73 2008/10/09 16:00:05 deraadt Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.74 2009/01/13 13:36:12 blambert Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -1040,7 +1040,7 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m0)
case SO_SNDBUF:
if (sbcheckreserve(cnt, so->so_snd.sb_hiwat) ||
- sbreserve(&so->so_snd, cnt) == 0) {
+ sbreserve(&so->so_snd, cnt)) {
error = ENOBUFS;
goto bad;
}
@@ -1048,7 +1048,7 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m0)
case SO_RCVBUF:
if (sbcheckreserve(cnt, so->so_rcv.sb_hiwat) ||
- sbreserve(&so->so_rcv, cnt) == 0) {
+ sbreserve(&so->so_rcv, cnt)) {
error = ENOBUFS;
goto bad;
}
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index 647edfce827..b7d1097b0ee 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.45 2008/11/24 12:57:37 dlg Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.46 2009/01/13 13:36:12 blambert Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@@ -364,9 +364,9 @@ int
soreserve(struct socket *so, u_long sndcc, u_long rcvcc)
{
- if (sbreserve(&so->so_snd, sndcc) == 0)
+ if (sbreserve(&so->so_snd, sndcc))
goto bad;
- if (sbreserve(&so->so_rcv, rcvcc) == 0)
+ if (sbreserve(&so->so_rcv, rcvcc))
goto bad2;
if (so->so_rcv.sb_lowat == 0)
so->so_rcv.sb_lowat = 1;
@@ -391,12 +391,12 @@ sbreserve(struct sockbuf *sb, u_long cc)
{
if (cc == 0 || cc > sb_max)
- return (0);
+ return (1);
sb->sb_hiwat = cc;
sb->sb_mbmax = min(cc * 2, sb_max + (sb_max / MCLBYTES) * MSIZE);
if (sb->sb_lowat > sb->sb_hiwat)
sb->sb_lowat = sb->sb_hiwat;
- return (1);
+ return (0);
}
/*