Re: [PATCH] waitid system call

Bill Davidsen
2004-08-31T15:52:26Z

Andrew Morton wrote:
> Jakub Jelinek <jakub@redhat.com> wrote:
>
>>On Mon, Aug 30, 2004 at 11:04:46PM -0700, Roland McGrath wrote:
>> > + /*
>> > + * For a WNOHANG return, clear out all the fields
>> > + * we would set so the user can easily tell the
>> > + * difference.
>> > + */
>> > + if (!retval)
>> > + retval = put_user(0, &infop->si_signo);
>> > + if (!retval)
>> > + retval = put_user(0, &infop->si_errno);
>> > + if (!retval)
>> > + retval = put_user(0, &infop->si_code);
>> > + if (!retval)
>> > + retval = put_user(0, &infop->si_pid);
>> > + if (!retval)
>> > + retval = put_user(0, &infop->si_uid);
>> > + if (!retval)
>> > + retval = put_user(0, &infop->si_status);
>>
>> Is it really necessary to check the exit code after each put_user?
>> if (!retval && access_ok(VERIFY_WRITE, infop, sizeof(*infop)))) {
>> retval = __put_user(0, &infop->si_signo);
>> retval |= __put_user(0, &infop->si_errno);
>> retval |= __put_user(0, &infop->si_code);
>> retval |= __put_user(0, &infop->si_pid);
>> retval |= __put_user(0, &infop->si_uid);
>> retval |= __put_user(0, &infop->si_status);
>> }
>> is what kernel usually does when filling multiple structure members.
>
>
> I don't think it matters much. Taking seven trips into the fault handler
> where one would do seems a bit dumb though.

If all you need is good/bad you could just separate the put_user calls
with || and only go through the error handler once.

--
-bill davidsen (davidsen@tmr.com)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me