Skip to content

Commit 328e8f6

Browse files
committed
include: Move safe_mmap into tst_safe_macros_inline.h
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: 3f571da ("include: Move inline functions to special header") Link: https://lore.kernel.org/ltp/20250227170524.3168535-1-pvorel@suse.cz/ Reviewed-by: Li Wang <liwang@redhat.com> Acked-by: Jan Stancek <jstancek@redhat.com> Acked-by: Andrea Cervesato <andrea.cervesato@suse.com> Signed-off-by: Petr Vorel <pvorel@suse.cz>
1 parent 62676d0 commit 328e8f6

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

include/tst_safe_macros.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -271,35 +271,6 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
271271
"fcntl(%i,%s,...) failed", fd, #cmd), 0 \
272272
: tst_ret_;})
273273

274-
void tst_prot_to_str(const int prot, char *buf);
275-
276-
static inline void *safe_mmap(const char *file, const int lineno,
277-
void *addr, size_t length, int prot, int flags, int fd, off_t offset)
278-
{
279-
void *rval;
280-
char prot_buf[512];
281-
282-
tst_prot_to_str(prot, prot_buf);
283-
284-
tst_res_(file, lineno, TDEBUG,
285-
"mmap(%p, %zu, %s(%x), %d, %d, %lld)",
286-
addr, length, prot_buf, prot, flags, fd, (long long int)offset);
287-
288-
rval = mmap(addr, length, prot, flags, fd, offset);
289-
if (rval == MAP_FAILED) {
290-
tst_brk_(file, lineno, TBROK | TERRNO,
291-
"mmap(%p,%zu,%s(%x),%d,%d,%ld) failed",
292-
addr, length, prot_buf, prot, flags, fd, (long) offset);
293-
}
294-
295-
return rval;
296-
}
297-
298-
299-
#define SAFE_MMAP(addr, length, prot, flags, fd, offset) \
300-
safe_mmap(__FILE__, __LINE__, (addr), (length), (prot), \
301-
(flags), (fd), (offset))
302-
303274
int safe_mprotect(const char *file, const int lineno,
304275
char *addr, size_t len, int prot);
305276

include/tst_safe_macros_inline.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,32 @@ static inline int safe_setrlimit(const char *file, const int lineno,
227227
#define SAFE_SETRLIMIT(resource, rlim) \
228228
safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
229229

230+
void tst_prot_to_str(const int prot, char *buf);
231+
232+
static inline void *safe_mmap(const char *file, const int lineno,
233+
void *addr, size_t length, int prot, int flags, int fd, off_t offset)
234+
{
235+
void *rval;
236+
char prot_buf[512];
237+
238+
tst_prot_to_str(prot, prot_buf);
239+
240+
tst_res_(file, lineno, TDEBUG,
241+
"mmap(%p, %zu, %s(%x), %d, %d, %lld)",
242+
addr, length, prot_buf, prot, flags, fd, (long long int)offset);
243+
244+
rval = mmap(addr, length, prot, flags, fd, offset);
245+
if (rval == MAP_FAILED) {
246+
tst_brk_(file, lineno, TBROK | TERRNO,
247+
"mmap(%p,%zu,%s(%x),%d,%d,%ld) failed",
248+
addr, length, prot_buf, prot, flags, fd, (long) offset);
249+
}
250+
251+
return rval;
252+
}
253+
254+
#define SAFE_MMAP(addr, length, prot, flags, fd, offset) \
255+
safe_mmap(__FILE__, __LINE__, (addr), (length), (prot), \
256+
(flags), (fd), (offset))
257+
230258
#endif /* TST_SAFE_MACROS_INLINE_H__ */

0 commit comments

Comments
 (0)