Hi Andreas,
On 11.04.20 22:05, Andreas Schwab wrote:
> * unit-tests/test-dl.c (test_fn_check): Avoid strict aliasing
> violation.
> ---
> unit-tests/test-dl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/unit-tests/test-dl.c b/unit-tests/test-dl.c
> index d996bba5..51e73239 100644
> --- a/unit-tests/test-dl.c
> +++ b/unit-tests/test-dl.c
> @@ -183,7 +183,7 @@ static void test_fn_check(void *fn, const char *expected)
> {
> char buf[16];
> test_fn fn_p;
> - *((void **) &fn_p) = fn;
> + fn_p = (test_fn)fn;
> (*fn_p)(buf, sizeof(buf));
> if (strncmp(buf, expected, 15) != 0)
> abortmsg("Test function returned %s, expected %s", buf,
> expected);
>
Your changes result in
test-dl.c: In function 'test_fn_check':
test-dl.c:186:9: warning: ISO C forbids conversion of object pointer to
function pointer type [-Wpedantic]
186 | fn_p = (test_fn)fn;
| ^
Following the code, tt basically turns down to the question "How to
convert dlsym() return value into a function pointer correctly".
Regards, Tim
signature.asc
Description: OpenPGP digital signature
