[LTP] [PATCH 2/4] syscalls/ipc: shmctl04: Require full fscanf match

Guixiong Wei via ltp
2026-02-23T10:59:26Z

Stop parsing /proc/sysvipc/shm when fscanf() does not match all
expected fields, to avoid using stale values from previous iterations.

Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com>
---
testcases/kernel/syscalls/ipc/shmctl/shmctl04.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
index 908cd2926..967e5d4b2 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl04.c
@@ -68,7 +68,7 @@ static void parse_proc_sysvipc(struct shm_info *info)
* size.
*/
while (fscanf(f, "%*i %i %*i %lu %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %i %i",
- &shmid, &size, &rss, &swap) > 0) {
+ &shmid, &size, &rss, &swap) == 4) {
used_ids++;
shm_rss += rss/page_size;
shm_swp += swap/page_size;
--
2.20.1