From: Emil Velikov Date: Sat, 24 May 2025 12:02:48 +0000 (+0100) Subject: testsuite/path: cache the old dlsym() results X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aedcfbab7425ea09acbe96a7120d714289fa4a1a;p=thirdparty%2Fkmod.git testsuite/path: cache the old dlsym() results 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 Link: https://github.com/kmod-project/kmod/pull/355 Signed-off-by: Lucas De Marchi --- diff --git a/testsuite/path.c b/testsuite/path.c index 06060b85..bf9ade1b 100644 --- a/testsuite/path.c +++ b/testsuite/path.c @@ -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; \