[LTP] [PATCH v2 1/1] include: Move safe_mmap into tst_safe_macros_inline.h
Petr Vorel
pvorel@suse.cz
Thu Feb 27 18:05:24 CET 2025
tst_safe_macros_inline.h contains functions which are forced to be
'inline' because the behaviour may depend on -D_FILE_OFFSET_BITS=64
compile flag (type off_t or structures containing off_t fields).
safe_mmap() was left from this conversion.
Fixes: 3f571da28d ("include: Move inline functions to special header")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v1->v2:
* Fix build by moving also tst_prot_to_str() signature.
Link to v1
https://patchwork.ozlabs.org/project/ltp/patch/20250227165817.3166403-1-pvorel@suse.cz/
Tested:
https://github.com/pevik/ltp/actions/runs/13571853789
include/tst_safe_macros.h | 29 -----------------------------
include/tst_safe_macros_inline.h | 28 ++++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 6985aa4bd8..3b02f86c76 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -271,35 +271,6 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
"fcntl(%i,%s,...) failed", fd, #cmd), 0 \
: tst_ret_;})
-void tst_prot_to_str(const int prot, char *buf);
-
-static inline void *safe_mmap(const char *file, const int lineno,
- void *addr, size_t length, int prot, int flags, int fd, off_t offset)
-{
- void *rval;
- char prot_buf[512];
-
- tst_prot_to_str(prot, prot_buf);
-
- tst_res_(file, lineno, TDEBUG,
- "mmap(%p, %zu, %s(%x), %d, %d, %lld)",
- addr, length, prot_buf, prot, flags, fd, (long long int)offset);
-
- rval = mmap(addr, length, prot, flags, fd, offset);
- if (rval == MAP_FAILED) {
- tst_brk_(file, lineno, TBROK | TERRNO,
- "mmap(%p,%zu,%s(%x),%d,%d,%ld) failed",
- addr, length, prot_buf, prot, flags, fd, (long) offset);
- }
-
- return rval;
-}
-
-
-#define SAFE_MMAP(addr, length, prot, flags, fd, offset) \
- safe_mmap(__FILE__, __LINE__, (addr), (length), (prot), \
- (flags), (fd), (offset))
-
int safe_mprotect(const char *file, const int lineno,
char *addr, size_t len, int prot);
diff --git a/include/tst_safe_macros_inline.h b/include/tst_safe_macros_inline.h
index 5eed3a18d0..15b756860e 100644
--- a/include/tst_safe_macros_inline.h
+++ b/include/tst_safe_macros_inline.h
@@ -227,4 +227,32 @@ static inline int safe_setrlimit(const char *file, const int lineno,
#define SAFE_SETRLIMIT(resource, rlim) \
safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
+void tst_prot_to_str(const int prot, char *buf);
+
+static inline void *safe_mmap(const char *file, const int lineno,
+ void *addr, size_t length, int prot, int flags, int fd, off_t offset)
+{
+ void *rval;
+ char prot_buf[512];
+
+ tst_prot_to_str(prot, prot_buf);
+
+ tst_res_(file, lineno, TDEBUG,
+ "mmap(%p, %zu, %s(%x), %d, %d, %lld)",
+ addr, length, prot_buf, prot, flags, fd, (long long int)offset);
+
+ rval = mmap(addr, length, prot, flags, fd, offset);
+ if (rval == MAP_FAILED) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "mmap(%p,%zu,%s(%x),%d,%d,%ld) failed",
+ addr, length, prot_buf, prot, flags, fd, (long) offset);
+ }
+
+ return rval;
+}
+
+#define SAFE_MMAP(addr, length, prot, flags, fd, offset) \
+ safe_mmap(__FILE__, __LINE__, (addr), (length), (prot), \
+ (flags), (fd), (offset))
+
#endif /* TST_SAFE_MACROS_INLINE_H__ */
--
2.47.2
More information about the ltp
mailing list