All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1 2/2] lib: moves test infrastructure states into a shared context structure
Date: Thu, 5 Jun 2025 14:40:45 +0200	[thread overview]
Message-ID: <aEGQTfxMGWZ2pSHJ@yuki.lan> (raw)
In-Reply-To: <CAEemH2erR_5qOk-ixhMMd2L0=RLH=RvDdSBdeiWWPXNtE60_QQ@mail.gmail.com>

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2025-06-05 12:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-15  1:58 [LTP] [PATCH v1 0/2] Refactor test state handling and clarify naming in lib Li Wang via ltp
2025-05-15  1:58 ` [LTP] [PATCH v1 1/2] lib: rename tid to tcid Li Wang via ltp
2025-06-04  9:45   ` Cyril Hrubis
2025-06-05  2:28     ` Li Wang via ltp
2025-05-15  1:58 ` [LTP] [PATCH v1 2/2] lib: moves test infrastructure states into a shared context structure Li Wang via ltp
2025-05-15 13:16   ` Petr Vorel
2025-06-04  7:04     ` Li Wang via ltp
2025-06-04 11:55   ` Cyril Hrubis
2025-06-05  3:32     ` Li Wang via ltp
2025-06-05 12:40       ` Cyril Hrubis [this message]
2025-06-05  6:56     ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aEGQTfxMGWZ2pSHJ@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.