Make tnc_buffer() only return bytes actually read
This commit is contained in:
parent
e7b1c2cf54
commit
6a427c4097
1 changed files with 3 additions and 3 deletions
|
@ -68,14 +68,14 @@ void patty_kiss_tnc_close(patty_kiss_tnc *tnc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t tnc_buffer(patty_kiss_tnc *tnc) {
|
static ssize_t tnc_buffer(patty_kiss_tnc *tnc) {
|
||||||
size_t fillsz = tnc->bufsz - tnc->buflen;
|
size_t fillsz = tnc->bufsz - tnc->buflen;
|
||||||
|
ssize_t readlen = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the buffer needs to be filled, then fill it.
|
* If the buffer needs to be filled, then fill it.
|
||||||
*/
|
*/
|
||||||
if (fillsz) {
|
if (fillsz) {
|
||||||
void *dest = ((unsigned char *)tnc->buf) + tnc->buflen;
|
void *dest = ((unsigned char *)tnc->buf) + tnc->buflen;
|
||||||
ssize_t readlen;
|
|
||||||
|
|
||||||
if ((readlen = read(tnc->fd, dest, fillsz)) < 0) {
|
if ((readlen = read(tnc->fd, dest, fillsz)) < 0) {
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
|
@ -86,7 +86,7 @@ static ssize_t tnc_buffer(patty_kiss_tnc *tnc) {
|
||||||
tnc->buflen += readlen;
|
tnc->buflen += readlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tnc->buflen;
|
return readlen;
|
||||||
|
|
||||||
error_io:
|
error_io:
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue