[LTP] [PATCH v4 02/12] Add SAFE_PTSNAME macro
Andrea Cervesato
andrea.cervesato@suse.de
Thu Jan 16 12:36:01 CET 2025
From: Andrea Cervesato <andrea.cervesato@suse.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
include/tst_safe_macros.h | 4 ++++
lib/tst_safe_macros.c | 14 ++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index a9fa7dbe128f17eace381fdf9f2795684e55969b..6985aa4bd80af2ff8a7c606fdba9830bb5ccd195 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -528,4 +528,8 @@ ssize_t safe_writev(const char *file, const int lineno, char len_strict,
safe_writev(__FILE__, __LINE__, (len_strict), (fildes), \
(iov), (iovcnt))
+char *safe_ptsname(const char *const file, const int lineno, int masterfd);
+#define SAFE_PTSNAME(masterfd) \
+ safe_ptsname(__FILE__, __LINE__, (masterfd))
+
#endif /* TST_SAFE_MACROS_H__ */
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
index 633b00404a56aafce6322e43bd614070d085e643..ba095a6215a8a053ad7397b4a541b26f02439b0f 100644
--- a/lib/tst_safe_macros.c
+++ b/lib/tst_safe_macros.c
@@ -796,3 +796,17 @@ ssize_t safe_writev(const char *file, const int lineno, char len_strict,
return rval;
}
+
+char *safe_ptsname(const char *const file, const int lineno, int masterfd)
+{
+ char *name;
+
+ name = ptsname(masterfd);
+
+ if (!name) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "ptsname(%d) failed", masterfd);
+ }
+
+ return name;
+}
--
2.43.0
More information about the ltp
mailing list