diff options
author | Alexander Færøy <ahf@torproject.org> | 2017-02-27 15:42:57 +0100 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2017-03-01 21:26:27 +0100 |
commit | 3dca5a6e71929f88c9c76f6ebbaac58789884b6e (patch) | |
tree | 98494b44b88ba4eecbe3a919fb9d288da4c17de1 /src/test/test_util.c | |
parent | 498287b3c340739bede9a3fa95ea23b6ae650bf3 (diff) | |
download | tor-3dca5a6e71929f88c9c76f6ebbaac58789884b6e.tar.gz tor-3dca5a6e71929f88c9c76f6ebbaac58789884b6e.zip |
Use tor_fgets() instead of fgets().
This patch changes our use of fgets() to tor_fgets() for more consistent
error handling across different versions of the C library.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 5b4d5b7703..7a6991650d 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -3972,16 +3972,16 @@ test_util_fgets_eagain(void *ptr) /* Send in a partial line */ retlen = write(test_pipe[1], "A", 1); tt_int_op(retlen, OP_EQ, 1); - retptr = fgets(buf, sizeof(buf), test_stream); + retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, EAGAIN); - tt_ptr_op(retptr, OP_EQ, buf); + tt_ptr_op(retptr, OP_EQ, NULL); tt_str_op(buf, OP_EQ, "A"); errno = 0; /* Send in the rest */ retlen = write(test_pipe[1], "B\n", 2); tt_int_op(retlen, OP_EQ, 2); - retptr = fgets(buf, sizeof(buf), test_stream); + retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "B\n"); @@ -3990,7 +3990,7 @@ test_util_fgets_eagain(void *ptr) /* Send in a full line */ retlen = write(test_pipe[1], "CD\n", 3); tt_int_op(retlen, OP_EQ, 3); - retptr = fgets(buf, sizeof(buf), test_stream); + retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "CD\n"); @@ -3999,16 +3999,16 @@ test_util_fgets_eagain(void *ptr) /* Send in a partial line */ retlen = write(test_pipe[1], "E", 1); tt_int_op(retlen, OP_EQ, 1); - retptr = fgets(buf, sizeof(buf), test_stream); + retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, EAGAIN); - tt_ptr_op(retptr, OP_EQ, buf); + tt_ptr_op(retptr, OP_EQ, NULL); tt_str_op(buf, OP_EQ, "E"); errno = 0; /* Send in the rest */ retlen = write(test_pipe[1], "F\n", 2); tt_int_op(retlen, OP_EQ, 2); - retptr = fgets(buf, sizeof(buf), test_stream); + retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "F\n"); @@ -4020,14 +4020,14 @@ test_util_fgets_eagain(void *ptr) retval = close(test_pipe[1]); tt_int_op(retval, OP_EQ, 0); test_pipe[1] = -1; - retptr = fgets(buf, sizeof(buf), test_stream); + retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "GH"); errno = 0; /* Check for EOF */ - retptr = fgets(buf, sizeof(buf), test_stream); + retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, NULL); retval = feof(test_stream); |