On 6 February 2014 06:56, Michael Tokarev <m...@tls.msk.ru> wrote:
> socketcall is just a dispatcher, it accepts an array of ulongs and should
> call the right socket function.  We tried to handle arguments for every
> function case, and did that differently, which in the past caused errors
> due to wrong types or sizes used.  So instead of extracting args in every
> case, do it once (based on a small mapping of function num. to argument count)
> and once this is done, just call the right function passing it the extracted
> args in a ready to use form.  This also simplifies the function alot.
> +    /* first extract args from vptr according to ac[num] if num is correct */
> +    if (num >= 0 && num < ARRAY_SIZE(ac)) {
> +        unsigned i;

I think it would be nice to have here:
    assert(ac[num] <= ARRAY_SIZE(a));

just as a reminder to bump the ac[] array size if anybody adds a 7-argument
function in future.

Otherwise
Reviewed-by: Peter Maydell <peter.mayd...@linaro.org>

Incidentally this is how the kernel itself handles socketcall, so
putting everything into abi_ulongs is semantically correct. (The
kernel's mechanism for looking up the number of arguments for
each call type is IMHO uglier and less maintainable though :-))

thanks
-- PMM

Reply via email to