[LTP] [PATCH 2/2] Update old API call sites of SAFE_READ() to use the enum values
Victor Cheng-Yen Yang
cyyang772@andestech.com
Tue Oct 6 04:03:31 CEST 2026
From: Victor Cheng-Yen Yang <cyyang772@andestech.com>
The old test.h API shares safe_read() with the new one, so the same
SAFE_READ_ANY / SAFE_READ_ALL constants apply there. Convert the old API
callers for the same reason as the new API ones: the intent of every
call site becomes visible without looking up the prototype.
No functional change.
Signed-off-by: Victor Cheng-Yen Yang <cyyang772@andestech.com>
---
lib/tests/tst_safe_macros.c | 4 ++--
testcases/kernel/syscalls/fcntl/fcntl11.c | 4 ++--
testcases/kernel/syscalls/fcntl/fcntl31.c | 2 +-
testcases/kernel/syscalls/linkat/linkat01.c | 3 ++-
testcases/kernel/syscalls/openat/openat03.c | 2 +-
testcases/kernel/syscalls/renameat2/renameat202.c | 2 +-
testcases/kernel/syscalls/symlinkat/symlinkat01.c | 3 ++-
testcases/kernel/syscalls/umount2/umount2_01.c | 2 +-
8 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/lib/tests/tst_safe_macros.c b/lib/tests/tst_safe_macros.c
index 59b9b49bb..241ac0daa 100644
--- a/lib/tests/tst_safe_macros.c
+++ b/lib/tests/tst_safe_macros.c
@@ -27,9 +27,9 @@ int main(int argc LTP_ATTRIBUTE_UNUSED, char **argv)
printf("%s\n", SAFE_BASENAME(NULL, *argv));
printf("%s\n", SAFE_DIRNAME(NULL, *argv));
fd = SAFE_OPEN(cleanup, __FILE__ "~", O_RDWR);
- SAFE_READ(cleanup, 0, fd, buf, 9);
+ SAFE_READ(cleanup, SAFE_READ_ANY, fd, buf, 9);
printf("buf: %s\n", buf);
- SAFE_READ(cleanup, 1, fd, buf, 9);
+ SAFE_READ(cleanup, SAFE_READ_ALL, fd, buf, 9);
printf("buf: %s\n", buf);
SAFE_WRITE(cleanup, SAFE_WRITE_ANY, -1, buf, 9);
SAFE_WRITE(NULL, SAFE_WRITE_ANY, fd, buf, 9);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl11.c b/testcases/kernel/syscalls/fcntl/fcntl11.c
index 083055dd5..bf46f38d1 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl11.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl11.c
@@ -208,7 +208,7 @@ void parent_put(struct flock *l)
void parent_get(struct flock *l)
{
- SAFE_READ(cleanup, 1, child_pipe[0], l, sizeof(*l));
+ SAFE_READ(cleanup, SAFE_READ_ALL, child_pipe[0], l, sizeof(*l));
}
void child_put(struct flock *l)
@@ -218,7 +218,7 @@ void child_put(struct flock *l)
void child_get(struct flock *l)
{
- SAFE_READ(NULL, 1, parent_pipe[0], l, sizeof(*l));
+ SAFE_READ(NULL, SAFE_READ_ALL, parent_pipe[0], l, sizeof(*l));
if (l->l_type == (short)STOP)
exit(0);
}
diff --git a/testcases/kernel/syscalls/fcntl/fcntl31.c b/testcases/kernel/syscalls/fcntl/fcntl31.c
index 2aab4a91c..2a74b7478 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl31.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl31.c
@@ -344,7 +344,7 @@ static void check_io_signal(char *des)
"signal mechanism work abnormally");
}
- SAFE_READ(cleanup, 1, test_fd, &c, 1);
+ SAFE_READ(cleanup, SAFE_READ_ALL, test_fd, &c, 1);
wait(NULL);
}
}
diff --git a/testcases/kernel/syscalls/linkat/linkat01.c b/testcases/kernel/syscalls/linkat/linkat01.c
index fa2065bbb..c3851874d 100644
--- a/testcases/kernel/syscalls/linkat/linkat01.c
+++ b/testcases/kernel/syscalls/linkat/linkat01.c
@@ -249,7 +249,8 @@ static void mylinkat_test(struct test_struct *desc)
fd = SAFE_OPEN(cleanup, desc->referencefn2,
O_RDONLY);
- SAFE_READ(cleanup, 1, fd, &vnum, sizeof(vnum));
+ SAFE_READ(cleanup, SAFE_READ_ALL, fd, &vnum,
+ sizeof(vnum));
SAFE_CLOSE(cleanup, fd);
if (tnum == vnum)
diff --git a/testcases/kernel/syscalls/openat/openat03.c b/testcases/kernel/syscalls/openat/openat03.c
index 712e85745..2406f9c58 100644
--- a/testcases/kernel/syscalls/openat/openat03.c
+++ b/testcases/kernel/syscalls/openat/openat03.c
@@ -129,7 +129,7 @@ static void read_file(int fd)
SAFE_LSEEK(cleanup, fd, 0, SEEK_SET);
for (i = 0; i < blocks_num; ++i) {
- SAFE_READ(cleanup, 0, fd, tmp, size);
+ SAFE_READ(cleanup, SAFE_READ_ANY, fd, tmp, size);
if (memcmp(buf, tmp, size))
tst_brkm(TFAIL, cleanup, "got unexepected data");
}
diff --git a/testcases/kernel/syscalls/renameat2/renameat202.c b/testcases/kernel/syscalls/renameat2/renameat202.c
index a635206f7..d5def6e83 100644
--- a/testcases/kernel/syscalls/renameat2/renameat202.c
+++ b/testcases/kernel/syscalls/renameat2/renameat202.c
@@ -141,7 +141,7 @@ static void renameat2_verify(void)
SAFE_STAT(cleanup, emptyfile, &st);
- readn = SAFE_READ(cleanup, 0, fd, str, BUFSIZ);
+ readn = SAFE_READ(cleanup, SAFE_READ_ANY, fd, str, BUFSIZ);
if (close(fd) < 0)
tst_brkm(TERRNO | TFAIL, cleanup, "close fd failed");
diff --git a/testcases/kernel/syscalls/symlinkat/symlinkat01.c b/testcases/kernel/syscalls/symlinkat/symlinkat01.c
index 565e4d923..285e75d8c 100644
--- a/testcases/kernel/syscalls/symlinkat/symlinkat01.c
+++ b/testcases/kernel/syscalls/symlinkat/symlinkat01.c
@@ -181,7 +181,8 @@ static void mysymlinkat_test(struct test_struct *desc)
SAFE_CLOSE(cleanup, fd);
fd = SAFE_OPEN(cleanup, desc->referencefn2, O_RDONLY);
- SAFE_READ(cleanup, 1, fd, &vnum, sizeof(vnum));
+ SAFE_READ(cleanup, SAFE_READ_ALL, fd, &vnum,
+ sizeof(vnum));
SAFE_CLOSE(cleanup, fd);
if (tnum == vnum)
diff --git a/testcases/kernel/syscalls/umount2/umount2_01.c b/testcases/kernel/syscalls/umount2/umount2_01.c
index c6496e306..9e0732461 100644
--- a/testcases/kernel/syscalls/umount2/umount2_01.c
+++ b/testcases/kernel/syscalls/umount2/umount2_01.c
@@ -128,7 +128,7 @@ static void umount2_verify(void)
memset(buf, 0, sizeof(buf));
- SAFE_READ(cleanup, 1, fd, buf, strlen(str));
+ SAFE_READ(cleanup, SAFE_READ_ALL, fd, buf, strlen(str));
if (strcmp(str, buf)) {
tst_resm(TFAIL, "umount2(2) MNT_DETACH flag "
--
2.55.0
More information about the ltp
mailing list