[LTP] [PATCH 1/2] lib: initialize lib|main_pid to zero in the setup_ipc
Petr Vorel
pvorel@suse.cz
Tue May 13 17:41:59 CEST 2025
> On Tue, May 13, 2025 at 9:02 PM Li Wang <liwang@redhat.com> wrote:
> > On Tue, May 13, 2025 at 8:52 PM Petr Vorel <pvorel@suse.cz> wrote:
> > > Hi all,
> > > ...
> > > > > +++ b/lib/tst_test.c
> > > > > @@ -59,7 +59,6 @@ static const char *tid;
> > > > > static int iterations = 1;
> > > > > static float duration = -1;
> > > > > static float timeout_mul = -1;
> > > > > -static pid_t lib_pid;
> > > > > static int mntpoint_mounted;
> > > > > static int ovl_mounted;
> > > > > static struct timespec tst_start_time; /* valid only for test pid */
> > > > > @@ -143,7 +142,9 @@ static void setup_ipc(void)
> > > > > tst_futexes = (char *)results + sizeof(struct results);
> > > > > tst_max_futexes = (size - sizeof(struct results))/sizeof(futex_t);
> > > > > }
> > > > > - results->lib_pid = lib_pid;
> > > > > +
> > > > > + results->lib_pid = 0;
> > > > > + results->main_pid = 0;
> > > nit: Is it really needed to int them to 0? Because they should be 0 due the
> > > default struct value, right?
> The results structure memory was dynamically allocated via
> mmap so the default value might not be zero. Unless we do
> explicitly call memset(, 0, ...).
Thanks for info. Or just use {} instead of memset?
struct results saved_results = {};
Tiny detail, just it's more readable to me.
Kind regards,
Petr
More information about the ltp
mailing list