[LTP] [PATCH 1/2] lib: initialize lib|main_pid to zero in the setup_ipc
Li Wang
liwang@redhat.com
Tue May 13 15:06:58 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, ...).
--
Regards,
Li Wang
More information about the ltp
mailing list