]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite/path: cache the old dlsym() results
authorEmil Velikov <emil.l.velikov@gmail.com>
Sat, 24 May 2025 12:02:48 +0000 (13:02 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 29 May 2025 22:30:13 +0000 (17:30 -0500)
There is no need for us to repeatedly fetch the respective symbols.
Based on the static storage of _fn, this must have been the goal since
day 1.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/355
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
testsuite/path.c

index 06060b85be5b0b14f1c6fd7ce0a1435046a5ad6e..bf9ade1b6d4e6555df7b92150bb2323c59d4c848 100644 (file)
@@ -103,7 +103,8 @@ static void *get_libc_func(const char *f)
                                                      \
                if (!get_rootpath(__func__))         \
                        return failret;              \
-               _fn = get_libc_func(#name);          \
+               if (_fn == NULL)                     \
+                       _fn = get_libc_func(#name);  \
                p = trap_path(path, buf);            \
                if (p == NULL)                       \
                        return failret;              \
@@ -120,7 +121,8 @@ static void *get_libc_func(const char *f)
                                                                  \
                if (!get_rootpath(__func__))                     \
                        return failret;                          \
-               _fn = get_libc_func(#name);                      \
+               if (_fn == NULL)                                 \
+                       _fn = get_libc_func(#name);              \
                p = trap_path(path, buf);                        \
                if (p == NULL)                                   \
                        return failret;                          \
@@ -137,7 +139,8 @@ static void *get_libc_func(const char *f)
                                                                      \
                if (!get_rootpath(__func__))                         \
                        return -1;                                   \
-               _fn = get_libc_func("open" #suffix);                 \
+               if (_fn == NULL)                                     \
+                       _fn = get_libc_func("open" #suffix);         \
                p = trap_path(path, buf);                            \
                if (p == NULL)                                       \
                        return -1;                                   \
@@ -162,7 +165,8 @@ static void *get_libc_func(const char *f)
                const char *p;                                                       \
                char buf[PATH_MAX * 2];                                              \
                static int (*_fn)(int ver, const char *path, struct stat##suffix *); \
-               _fn = get_libc_func(#prefix "stat" #suffix);                         \
+               if (_fn == NULL)                                                     \
+                       _fn = get_libc_func(#prefix "stat" #suffix);                 \
                                                                                      \
                if (!get_rootpath(__func__))                                         \
                        return -1;                                                   \