[LTP] [PATCH 1/1] lib: Add missing inline

Petr Vorel pvorel@suse.cz
Mon Mar 18 15:54:36 CET 2024


Fixes: b366afb64 ("Add SAFE_MPROTECT() macro")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi Andrea, Cyril,

9120d8a22 ("safe_macros: turn functions with off_t parameter into static inline")
noted:

    Some functions used to implement safe macros have parameters
    of type off_t or structures containing off_t fields.

These functions (safe_mmap(), safe_stat(), safe_lstat(), ...) are
therefore below this comment:

/*
 * following functions are inline because the behaviour may depend on
 * -D_FILE_OFFSET_BITS=64 compile flag
 */

But IMHO that's not the case for safe_prot_to_str(), or am I missing
something? It does not use any struct, thus no off_t. And what about
safe_mprotect() (added in the same commit).

If I'm correct, I would prefer to move it (+ other functions added in
9120d8a22 to lib/tst_safe_macros.c and keep here only their signatures.

First, it document properly what depends on -D_FILE_OFFSET_BITS=64,
second, this approach to avoid static inline in headers started by
Martin Doucha is IMHO cleaner.

Kind regards,
Petr

 include/tst_safe_macros.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 7178a842d..463b0f7a9 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -271,7 +271,7 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
 
 #define PROT_FLAG_STR(f) #f " | "
 
-static void safe_prot_to_str(const int prot, char *buf)
+static inline void safe_prot_to_str(const int prot, char *buf)
 {
 	char *ptr = buf;
 
-- 
2.43.0



More information about the ltp mailing list