diff mbox series

[COMMITTED] syscalls/getdents01: Fix dirp handling

Message ID 20210426141700.20036-1-chrubis@suse.cz
State Accepted
Headers show
Series [COMMITTED] syscalls/getdents01: Fix dirp handling | expand

Commit Message

Cyril Hrubis April 26, 2021, 2:17 p.m. UTC
After previous fix the test still failed with large enough -i parameter,
e.g. -i 10, that was because we incremented the dirp in the run() loop.

This patch fixes that by simply using a different pointer for the loop
that check the buffer content.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/getdents/getdents01.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/getdents/getdents01.c b/testcases/kernel/syscalls/getdents/getdents01.c
index f36f8869a..e5e4689ee 100644
--- a/testcases/kernel/syscalls/getdents/getdents01.c
+++ b/testcases/kernel/syscalls/getdents/getdents01.c
@@ -81,16 +81,18 @@  static void run(void)
 
 	reset_flags();
 
+	void *recp = dirp;
+
 	do {
-		size_t d_reclen = tst_dirp_reclen(dirp);
-		const char *d_name = tst_dirp_name(dirp);
+		size_t d_reclen = tst_dirp_reclen(recp);
+		const char *d_name = tst_dirp_name(recp);
 
 		set_flag(d_name);
 
 		tst_res(TINFO, "Found '%s'", d_name);
 
 		rval -= d_reclen;
-		dirp += d_reclen;
+		recp += d_reclen;
 	} while (rval > 0);
 
 	check_flags();