[LTP] [PATCH v1 2/2] lib: moves test infrastructure states into a shared context structure

Cyril Hrubis chrubis@suse.cz
Thu Jun 5 14:40:45 CEST 2025


Hi!
> I guess you were hoping:
> 
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -152,7 +152,7 @@ static void setup_ipc(void)
>         if (tst_test->needs_checkpoints) {
>                 tst_futexes = ipc->futexes;
> 
> -               size_t futexes_offset = (char *)ipc->futexes - (char *)ipc;
> +               size_t futexes_offset = offsetof(struct ipc_region,
> futexes);
>                 tst_max_futexes = (size - futexes_offset) / sizeof(futex_t);
>         }
> 
> @@ -208,7 +208,7 @@ void tst_reinit(void)
>         results = &ipc->results;
> 
>         tst_futexes = ipc->futexes;
> -       size_t futexes_offset = (char *)ipc->futexes - (char *)ipc;
> +       size_t futexes_offset = offsetof(struct ipc_region, futexes);
>         tst_max_futexes = (size - futexes_offset) / sizeof(futex_t);
> 
>         if (context->tdebug)

That's exactly what I've been asking for, to use offsetof() to calculate
the size of the structure we need to substract from the size.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list