summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2021-08-06 11:44:02 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2021-09-15 15:13:18 +0000
commitd7159b37699523966f5e7af69b1bd84e2a084fa4 (patch)
treebe8dd25136fb31328c6dfeff6d25adf65ce58343 /usr/src/lib/libc/port
parent74e3b2c76b52940c79c5399e1c9c91a35b2b0c16 (diff)
downloadillumos-joyent-d7159b37699523966f5e7af69b1bd84e2a084fa4.tar.gz
14005 eventfd_read/write() don't return failure
Reviewed by: Robert Mustacchi <rm@fingolfin.org> Reviewed by: Dan McDonald <danmcd@joyent.com> Approved by: Robert Mustacchi <rm@fingolfin.org>
Diffstat (limited to 'usr/src/lib/libc/port')
-rw-r--r--usr/src/lib/libc/port/sys/eventfd.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/usr/src/lib/libc/port/sys/eventfd.c b/usr/src/lib/libc/port/sys/eventfd.c
index f165491cc1..d0d42e8f74 100644
--- a/usr/src/lib/libc/port/sys/eventfd.c
+++ b/usr/src/lib/libc/port/sys/eventfd.c
@@ -11,6 +11,7 @@
/*
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
+ * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
*/
#include <sys/eventfd.h>
@@ -57,11 +58,17 @@ eventfd(unsigned int initval, int flags)
int
eventfd_read(int fd, eventfd_t *valp)
{
- return (read(fd, valp, sizeof (*valp)) < sizeof (*valp) ? -1 : 0);
+ ssize_t ret = read(fd, valp, sizeof (*valp));
+ if (ret == -1 || (size_t)ret < sizeof (*valp))
+ return (-1);
+ return (0);
}
int
eventfd_write(int fd, eventfd_t val)
{
- return (write(fd, &val, sizeof (val)) < sizeof (val) ? -1 : 0);
+ ssize_t ret = write(fd, &val, sizeof (val));
+ if (ret == -1 || (size_t)ret < sizeof (val))
+ return (-1);
+ return (0);
}