From: Carlo Arenas <carenas@gmail.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org,
gang.chen.5i5j@gmail.com, riku.voipio@iki.fi, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt
Date: Wed, 20 Sep 2017 10:29:59 -0700 [thread overview]
Message-ID: <CAPUEspjdyJ8_cwGPZFOAKs3NE83kdwXV-Ji6TTFYJf7MFQxvBg@mail.gmail.com> (raw)
In-Reply-To: <d8115e2d-7409-c6ea-3c8d-3aead5b5fa87@vivier.eu>
On Wed, Sep 20, 2017 at 1:39 AM, Laurent Vivier <laurent@vivier.eu> 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
next prev parent reply other threads:[~2017-09-20 17:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-19 8:15 [Qemu-devel] [PATCH v3] linux-user: syscall: Add SO_LINGER for setsockopt Carlo Marcelo Arenas Belón
2017-09-19 11:42 ` Laurent Vivier
2017-09-19 23:06 ` [Qemu-devel] [PATCH 1/3] linux-user: fix TARGET_SO_LINGER for sparc Carlo Marcelo Arenas Belón
2017-09-19 23:06 ` [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt Carlo Marcelo Arenas Belón
2017-09-20 8:39 ` Laurent Vivier
2017-09-20 17:29 ` Carlo Arenas [this message]
2017-09-20 18:53 ` Laurent Vivier
2017-09-20 23:03 ` Carlo Arenas
2017-09-19 23:06 ` [Qemu-devel] [PATCH 3/3] linux-user: add SO_LINGER to getsockopt Carlo Marcelo Arenas Belón
2017-09-20 9:09 ` Laurent Vivier
2017-09-20 8:26 ` [Qemu-devel] [PATCH 1/3] linux-user: fix TARGET_SO_LINGER for sparc Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPUEspjdyJ8_cwGPZFOAKs3NE83kdwXV-Ji6TTFYJf7MFQxvBg@mail.gmail.com \
--to=carenas@gmail.com \
--cc=gang.chen.5i5j@gmail.com \
--cc=laurent@vivier.eu \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).