summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-03-23 15:48:08 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2002-03-23 15:48:08 +0100
commitef91debc4d181be5c34207cf32d127b3058f4697 (patch)
tree95a1ca7a235fdbf117c75a724737843fac9568d1 /tools.c
parent63a3eb076ebc3591fdfeb8d57785f4d2b6b8786e (diff)
downloadvdr-ef91debc4d181be5c34207cf32d127b3058f4697.tar.gz
vdr-ef91debc4d181be5c34207cf32d127b3058f4697.tar.bz2
Fixed safe_write()
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools.c b/tools.c
index 21a91dc1..682a521c 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.60 2002/03/22 15:18:58 kls Exp $
+ * $Id: tools.c 1.61 2002/03/23 15:48:08 kls Exp $
*/
#include "tools.h"
@@ -33,7 +33,8 @@ ssize_t safe_read(int filedes, void *buffer, size_t size)
ssize_t safe_write(int filedes, const void *buffer, size_t size)
{
- ssize_t p = -1;
+ ssize_t p = 0;
+ ssize_t written = size;
const unsigned char *ptr = (const unsigned char *)buffer;
while (size > 0) {
p = write(filedes, ptr, size);
@@ -47,7 +48,7 @@ ssize_t safe_write(int filedes, const void *buffer, size_t size)
ptr += p;
size -= p;
}
- return p;
+ return p < 0 ? p : written;
}
void writechar(int filedes, char c)