[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt
From: |
Carlo Arenas |
Subject: |
Re: [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt |
Date: |
Wed, 20 Sep 2017 10:29:59 -0700 |
On Wed, Sep 20, 2017 at 1:39 AM, Laurent Vivier <address@hidden> wrote:
>
> Why did you remove "optname = SO_LINGER" and "if (optlen !=
> sizeof(struct target_linger))"?
>
the optname assignment is not really needed, since it is only used for the
setsockopt call and that call is clearer using SO_LINGER directly, so to
avoid hard to see bugs like :
http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg00980.html
the test for optlen is replaced by passing optlen to the underlying
setsockopt call directly, who would do the test and return the right error.
as an interesting note, I noticed when testing (in ubuntu artful x86_64)
that regardless of how you interpret the documentation, setsockopt won't
fail just because the len is smaller than the size of the struct, and
therefore that code was not equivalent to the setsockopt it was trying to
emulate, and therefore this change doesn't only make the code simpler but
also more correct IMHO
Carlo