mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Fixed safe_write()
This commit is contained in:
parent
63a3eb076e
commit
ef91debc4d
7
tools.c
7
tools.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#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 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;
|
const unsigned char *ptr = (const unsigned char *)buffer;
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
p = write(filedes, ptr, size);
|
p = write(filedes, ptr, size);
|
||||||
@ -47,7 +48,7 @@ ssize_t safe_write(int filedes, const void *buffer, size_t size)
|
|||||||
ptr += p;
|
ptr += p;
|
||||||
size -= p;
|
size -= p;
|
||||||
}
|
}
|
||||||
return p;
|
return p < 0 ? p : written;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writechar(int filedes, char c)
|
void writechar(int filedes, char c)
|
||||||
|
Loading…
Reference in New Issue
Block a user