summaryrefslogtreecommitdiffstats
path: root/src/test/test-copy.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-03-03 05:07:10 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-03-04 23:10:13 +0100
commitf5fbe71d956957ca7ceb6777aed05a416fc83a43 (patch)
tree67358d417604030867a979f216bbb79939a37844 /src/test/test-copy.c
parenttable: drop last SIZE_MAX from table_set_sort() and table_set_display() (diff)
downloadsystemd-f5fbe71d956957ca7ceb6777aed05a416fc83a43.tar.xz
systemd-f5fbe71d956957ca7ceb6777aed05a416fc83a43.zip
tree-wide: use UINT64_MAX or friends
Diffstat (limited to 'src/test/test-copy.c')
-rw-r--r--src/test/test-copy.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
index 211b4a4925..43118202b8 100644
--- a/src/test/test-copy.c
+++ b/src/test/test-copy.c
@@ -207,7 +207,7 @@ static void test_copy_bytes(void) {
assert_se(pipe2(pipefd, O_CLOEXEC) == 0);
- r = copy_bytes(infd, pipefd[1], (uint64_t) -1, 0);
+ r = copy_bytes(infd, pipefd[1], UINT64_MAX, 0);
assert_se(r == 0);
r = read(pipefd[0], buf, sizeof(buf));
@@ -249,7 +249,7 @@ static void test_copy_bytes_regular_file(const char *src, bool try_reflink, uint
assert_se(fd3 >= 0);
r = copy_bytes(fd, fd2, max_bytes, try_reflink ? COPY_REFLINK : 0);
- if (max_bytes == (uint64_t) -1)
+ if (max_bytes == UINT64_MAX)
assert_se(r == 0);
else
assert_se(IN_SET(r, 0, 1));
@@ -258,14 +258,14 @@ static void test_copy_bytes_regular_file(const char *src, bool try_reflink, uint
assert_se(fstat(fd2, &buf2) == 0);
assert_se((uint64_t) buf2.st_size == MIN((uint64_t) buf.st_size, max_bytes));
- if (max_bytes < (uint64_t) -1)
+ if (max_bytes < UINT64_MAX)
/* Make sure the file is now higher than max_bytes */
assert_se(ftruncate(fd2, max_bytes + 1) == 0);
assert_se(lseek(fd2, 0, SEEK_SET) == 0);
r = copy_bytes(fd2, fd3, max_bytes, try_reflink ? COPY_REFLINK : 0);
- if (max_bytes == (uint64_t) -1)
+ if (max_bytes == UINT64_MAX)
assert_se(r == 0);
else
/* We cannot distinguish between the input being exactly max_bytes
@@ -277,7 +277,7 @@ static void test_copy_bytes_regular_file(const char *src, bool try_reflink, uint
assert_se(fstat(fd3, &buf3) == 0);
- if (max_bytes == (uint64_t) -1)
+ if (max_bytes == UINT64_MAX)
assert_se(buf3.st_size == buf2.st_size);
else
assert_se((uint64_t) buf3.st_size == max_bytes);
@@ -312,7 +312,7 @@ static void test_copy_proc(void) {
assert_se(mkdtemp_malloc(NULL, &p) >= 0);
assert_se(f = path_join(p, "version"));
- assert_se(copy_file("/proc/version", f, 0, (mode_t) -1, 0, 0, 0) >= 0);
+ assert_se(copy_file("/proc/version", f, 0, MODE_INVALID, 0, 0, 0) >= 0);
assert_se(read_one_line_file("/proc/version", &a) >= 0);
assert_se(read_one_line_file(f, &b) >= 0);
@@ -327,8 +327,8 @@ int main(int argc, char *argv[]) {
test_copy_file_fd();
test_copy_tree();
test_copy_bytes();
- test_copy_bytes_regular_file(argv[0], false, (uint64_t) -1);
- test_copy_bytes_regular_file(argv[0], true, (uint64_t) -1);
+ test_copy_bytes_regular_file(argv[0], false, UINT64_MAX);
+ test_copy_bytes_regular_file(argv[0], true, UINT64_MAX);
test_copy_bytes_regular_file(argv[0], false, 1000); /* smaller than copy buffer size */
test_copy_bytes_regular_file(argv[0], true, 1000);
test_copy_bytes_regular_file(argv[0], false, 32000); /* larger than copy buffer size */