mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
iobuf: Fix test.
* common/t-iobuf.c (content_filter): If there is nothing to read, don't forget to set *LEN to 0. (main): Fix checks. -- Signed-off-by: Neal H. Walfield <neal@g10code.com>.
This commit is contained in:
parent
9ba4ccdaf5
commit
8522cdc226
@ -111,15 +111,14 @@ content_filter (void *opaque, int control,
|
|||||||
if (toread > remaining)
|
if (toread > remaining)
|
||||||
toread = remaining;
|
toread = remaining;
|
||||||
|
|
||||||
if (toread == 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
memcpy (buf, &state->buffer[state->pos], toread);
|
memcpy (buf, &state->buffer[state->pos], toread);
|
||||||
|
|
||||||
state->pos += toread;
|
state->pos += toread;
|
||||||
|
|
||||||
*len = toread;
|
*len = toread;
|
||||||
|
|
||||||
|
if (toread == 0)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,10 +268,8 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
/* - 3 characters plus new line
|
/* - 10 characters, EOF
|
||||||
- 4 characters plus new line
|
- 17 characters, EOF
|
||||||
- 5 characters plus new line
|
|
||||||
- 5 characters, no new line
|
|
||||||
*/
|
*/
|
||||||
char *content = "abcdefghijklmnopq";
|
char *content = "abcdefghijklmnopq";
|
||||||
char *content2 = "0123456789";
|
char *content2 = "0123456789";
|
||||||
@ -294,7 +291,7 @@ main (int argc, char *argv[])
|
|||||||
if (c == -1 && lastc == -1)
|
if (c == -1 && lastc == -1)
|
||||||
{
|
{
|
||||||
/* printf("Two EOFs in a row. Done.\n"); */
|
/* printf("Two EOFs in a row. Done.\n"); */
|
||||||
assert (n == 44);
|
assert (n == 27);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +300,7 @@ main (int argc, char *argv[])
|
|||||||
if (c == -1)
|
if (c == -1)
|
||||||
{
|
{
|
||||||
/* printf("After %d bytes, got EOF.\n", n); */
|
/* printf("After %d bytes, got EOF.\n", n); */
|
||||||
assert (n == 27 || n == 44);
|
assert (n == 10 || n == 27);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user