[LTP] [PATCH 1/1] lapi/stat.h: Handle invalid __NR_fchmodat2 syscall return value
Petr Vorel
pvorel@suse.cz
Mon Aug 5 15:46:17 CEST 2024
Only 0 and -1 are valid for __NR_fchmodat2. Reporting invalid return
value is current approach for LTP safe macros.
While at it, unify the error message with safe macros.
Fixes: 49e1c012d3 ("Add fchmodat2 fallback definition")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
include/lapi/stat.h | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/lapi/stat.h b/include/lapi/stat.h
index 8e38ecfef1..030646a9e3 100644
--- a/include/lapi/stat.h
+++ b/include/lapi/stat.h
@@ -238,9 +238,15 @@ static inline int safe_fchmodat2(const char *file, const int lineno,
int ret;
ret = tst_syscall(__NR_fchmodat2, dfd, filename, mode, flags);
- if (ret == -1)
- tst_brk_(file, lineno, TBROK | TERRNO, "%s(%d,%s,%d,%d) error",
- __func__, dfd, filename, mode, flags);
+ if (ret == -1) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "syscall(__NR_fchmodat2,%d,%s,%d,%d) failed",
+ dfd, filename, mode, flags);
+ } else if (ret) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "Invalid syscall(__NR_fchmodat2,%d,%s,%d,%d) return value %d",
+ dfd, filename, mode, flags, ret);
+ }
return ret;
}
--
2.45.2
More information about the ltp
mailing list