Fix definition of write() to use const char * for the type of the buffer
This commit is contained in:
parent
204efa6bba
commit
a2e81650d1
@ -16,7 +16,7 @@
|
|||||||
#include "cio.h"
|
#include "cio.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
write_chunk (int fd, char *buf, int len)
|
write_chunk (int fd, const char *buf, int len)
|
||||||
{
|
{
|
||||||
__CIOBUF__.length[0] = len;
|
__CIOBUF__.length[0] = len;
|
||||||
__CIOBUF__.length[1] = len >> 8;
|
__CIOBUF__.length[1] = len >> 8;
|
||||||
@ -35,10 +35,11 @@ write_chunk (int fd, char *buf, int len)
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
write (int fd, char *buf, int len)
|
write (int fd, const char *buf, int len)
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int c;
|
int c;
|
||||||
|
int i = 0;
|
||||||
#if 0
|
#if 0
|
||||||
if (fd == 2)
|
if (fd == 2)
|
||||||
fprintf (stderr, "%.*s", buf, len);
|
fprintf (stderr, "%.*s", buf, len);
|
||||||
@ -48,12 +49,12 @@ write (int fd, char *buf, int len)
|
|||||||
while (len > 0)
|
while (len > 0)
|
||||||
{
|
{
|
||||||
int l = (len > CIO_BUF_SIZE) ? CIO_BUF_SIZE : len;
|
int l = (len > CIO_BUF_SIZE) ? CIO_BUF_SIZE : len;
|
||||||
c = write_chunk (fd, buf, l);
|
c = write_chunk (fd, buf + i, l);
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
return c;
|
return c;
|
||||||
rv += l;
|
rv += l;
|
||||||
len -= l;
|
len -= l;
|
||||||
buf += l;
|
i += l;
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user