chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d2febf7
)
util: loop_write - accept 0-length message
author
Tom Gundersen
<teg@jklm.no>
Fri, 15 May 2015 23:07:45 +0000
(
01:07
+0200)
committer
Sven Eden
<yamakuzure@gmx.net>
Tue, 14 Mar 2017 08:57:15 +0000
(09:57 +0100)
write() can send empty messages, so make sure loop_write() can do the same.
src/shared/util.c
patch
|
blob
|
history
diff --git
a/src/shared/util.c
b/src/shared/util.c
index d7a5b20946d886588e9a8541688f6bfd8cde1d6f..d3dacfcfb5300b0d55eb439273c277f2f7c0f0a5 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-1665,7
+1665,7
@@
int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
errno = 0;
-
while (nbytes > 0)
{
+
do
{
ssize_t k;
k = write(fd, p, nbytes);
@@
-1685,12
+1685,12
@@
int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
return -errno;
}
- if (k == 0) /* Can't really happen */
+ if (
nbytes > 0 &&
k == 0) /* Can't really happen */
return -EIO;
p += k;
nbytes -= k;
- }
+ }
while (nbytes > 0);
return 0;
}