[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH] linux-user: simplify/refactor socketcall impl

From: Peter Maydell
Subject: Re: [Qemu-trivial] [PATCH] linux-user: simplify/refactor socketcall implementation
Date: Wed, 12 Feb 2014 19:40:46 +0000

On 6 February 2014 06:56, Michael Tokarev <address@hidden> 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.

Reviewed-by: Peter Maydell <address@hidden>

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 :-))

-- PMM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]