From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MEW8a-0005C6-JU for qemu-devel@nongnu.org; Wed, 10 Jun 2009 18:19:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MEW8W-0005AM-3J for qemu-devel@nongnu.org; Wed, 10 Jun 2009 18:19:16 -0400 Received: from [199.232.76.173] (port=52286 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MEW8V-0005AH-SF for qemu-devel@nongnu.org; Wed, 10 Jun 2009 18:19:11 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:63525) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MEW8V-0001K5-B6 for qemu-devel@nongnu.org; Wed, 10 Jun 2009 18:19:11 -0400 Subject: Re: [Qemu-devel] [PATCH] linux-user: remove duplicate tswap32() from do_getsockopt() From: Laurent Vivier In-Reply-To: <20090610214254.GB23525@kos.to> References: <1243893468-17849-1-git-send-email-laurent@vivier.eu> <20090610214254.GB23525@kos.to> Content-Type: text/plain; charset=utf-8 Date: Thu, 11 Jun 2009 00:19:07 +0200 Message-Id: <1244672347.5770.3.camel@Quad> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Riku Voipio Cc: qemu-devel@nongnu.org Le jeudi 11 juin 2009 =C3=A0 00:42 +0300, Riku Voipio a =C3=A9crit : > On Mon, Jun 01, 2009 at 11:57:48PM +0200, Laurent Vivier wrote: > > This issue has been detected with tests/linux-tests.c: > >=20 > > linux-test.c:330: getsockopt > >=20 > > 327 len =3D sizeof(val); > > 328 chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len= )); > > 329 if (val !=3D SOCK_STREAM) > > 330 error("getsockopt"); > >=20 > > In linux-user/syscall.c:do_getsockopt(), we have: > > ... > > val =3D tswap32(val); > > ... > > if (put_user_u32(val, optval_addr)) > > ... > >=20 > > whereas "put_user_u32" calls in the end "__put_user" which uses "tswap3= 2". >=20 > > So the "val =3D tswap32(val);" is useless and wrong. >=20 > > This patch removes it. >=20 > makes sense, added to my tree. I think there might be quite a few broken > swapping going around.. Thank you. I'd like to see this in the qemu reference git tree, should I resend it ? > > Signed-off-by: Laurent Vivier > > --- > > linux-user/syscall.c | 1 - > > 1 files changed, 0 insertions(+), 1 deletions(-) > >=20 > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > > index a0915a4..b1bba48 100644 > > --- a/linux-user/syscall.c > > +++ b/linux-user/syscall.c > > @@ -1273,7 +1273,6 @@ static abi_long do_getsockopt(int sockfd, int lev= el, int optname, > > ret =3D get_errno(getsockopt(sockfd, level, optname, &val, &lv= )); > > if (ret < 0) > > return ret; > > - val =3D tswap32(val); > > if (len > lv) > > len =3D lv; > > if (len =3D=3D 4) { > > --=20 > > 1.5.6.5 > >=20 Regards, Laurent --=20 --------------------- laurent@vivier.eu ---------------------- "Tout ce qui est impossible reste =C3=A0 accomplir" Jules Verne "Things are only impossible until they're not" Jean-Luc Picard