[LTP] [PATCH 1/1] include: Move safe_mmap into tst_safe_macros_inline.h
Andrea Cervesato
andrea.cervesato@suse.com
Fri Feb 28 10:08:54 CET 2025
Hi!
Looks good to me.
Acked-by: Andrea Cervesato <andrea.cervesato@suse.com>
On 2/27/25 17:58, Petr Vorel wrote:
> 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>
> ---
> include/tst_safe_macros.h | 27 ---------------------------
> include/tst_safe_macros_inline.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 26 insertions(+), 27 deletions(-)
>
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 6985aa4bd8..d4b266297b 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -273,33 +273,6 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
>
> 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..7a7a2b0ddd 100644
> --- a/include/tst_safe_macros_inline.h
> +++ b/include/tst_safe_macros_inline.h
> @@ -227,4 +227,30 @@ static inline int safe_setrlimit(const char *file, const int lineno,
> #define SAFE_SETRLIMIT(resource, rlim) \
> safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
>
> +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__ */
More information about the ltp
mailing list