[LTP] [PATCH 2/2] setitimer03: convert to new API

Li Wang liwang@redhat.com
Thu Oct 20 11:30:19 CEST 2022


Richard Palethorpe <rpalethorpe@suse.de> wrote:


> > -static struct itimerval *value;
> > +static struct itimerval *value, *ovalue;
> > +
> > +static struct tcase {
> > +       int which;
> > +       struct itimerval **val;
> > +       struct itimerval **oval;
> > +       int exp_errno;
>
> There is a whitespace error here (see checkpatch/make check)
>

yes, thanks.



>
> > +} tcases[] = {
> > +       {ITIMER_REAL,    &value, &ovalue, EFAULT},
> > +       {ITIMER_VIRTUAL, &value, &ovalue, EFAULT},
> > +       {-ITIMER_PROF,   &value, &ovalue, EINVAL},
> > +};
>
> Why do we need value and ovalue in the struct?
>

Becuase it does not allow parsing an invalid pointer address
from a structure, we have to give a valid address which pointer
to save an invalid address. Otherwise segement fault will
be hit in execution.

And for the last test item, I don't want the invalid pointer to have
a side effect disturbs the first invalid argument.



>
> >
> >  static int sys_setitimer(int which, void *new_value, void *old_value)
> >  {
> >       return tst_syscall(__NR_setitimer, which, new_value, old_value);
> >  }
> >
> > -static void verify_setitimer(void)
> > +static void verify_setitimer(unsigned int i)
> >  {
> > -     TST_EXP_FAIL(sys_setitimer(ITIMER_REAL, value, (struct itimerval
> *)-1),
> > -                  EFAULT);
> > +        struct tcase *tc = &tcases[i];
> > +
> > +     if (tc->exp_errno == EFAULT)
> > +             *(tc->oval) = (struct itimerval *)-1;
>
> Or, why do we use an if statement here instead of defining it in the
> struct?
>

Same above, that's why here explicitly reassign an invalid address.


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20221020/c4cb6fce/attachment.htm>


More information about the ltp mailing list