<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Richard Palethorpe <<a href="mailto:rpalethorpe@suse.de">rpalethorpe@suse.de</a>> wrote:<br></div></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> -static struct itimerval *value;<br>
> +static struct itimerval *value, *ovalue;<br>
> +<br>
> +static struct tcase {<br>
> + int which;<br>
> + struct itimerval **val;<br>
> + struct itimerval **oval;<br>
> + int exp_errno;<br>
<br>
There is a whitespace error here (see checkpatch/make check)<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">yes, thanks.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> +} tcases[] = {<br>
> + {ITIMER_REAL, &value, &ovalue, EFAULT},<br>
> + {ITIMER_VIRTUAL, &value, &ovalue, EFAULT},<br>
> + {-ITIMER_PROF, &value, &ovalue, EINVAL},<br>
> +};<br>
<br>
Why do we need value and ovalue in the struct?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Becuase it does not allow parsing an invalid pointer address</div><div class="gmail_default" style="font-size:small">from a structure, we have to give a valid address which pointer</div><div class="gmail_default" style="font-size:small">to save an invalid address. Otherwise segement fault will</div><div class="gmail_default" style="font-size:small">be hit in execution.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">And for the last test item, I don't want the invalid pointer to have</div><div class="gmail_default" style="font-size:small">a side effect disturbs the first invalid argument.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> <br>
> static int sys_setitimer(int which, void *new_value, void *old_value)<br>
> {<br>
> return tst_syscall(__NR_setitimer, which, new_value, old_value);<br>
> }<br>
> <br>
> -static void verify_setitimer(void)<br>
> +static void verify_setitimer(unsigned int i)<br>
> {<br>
> - TST_EXP_FAIL(sys_setitimer(ITIMER_REAL, value, (struct itimerval *)-1),<br>
> - EFAULT);<br>
> + struct tcase *tc = &tcases[i];<br>
> +<br>
> + if (tc->exp_errno == EFAULT)<br>
> + *(tc->oval) = (struct itimerval *)-1;<br>
<br>
Or, why do we use an if statement here instead of defining it in the struct?<br></blockquote><div> </div><div><div class="gmail_default" style="font-size:small">Same above, that's why here explicitly reassign an invalid address. </div><br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>