From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29671 invoked by alias); 12 Apr 2010 15:52:00 -0000 Received: (qmail 29662 invoked by uid 22791); 12 Apr 2010 15:51:58 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Apr 2010 15:51:53 +0000 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 66A2C1B40F3; Mon, 12 Apr 2010 15:51:37 +0000 (UTC) From: Mike Frysinger To: Joel Brobecker Subject: Re: [PATCH] sim: tweak signed to unsigned local vars Date: Mon, 12 Apr 2010 15:52:00 -0000 User-Agent: KMail/1.13.1 (Linux/2.6.33.2; KDE/4.4.1; x86_64; ; ) Cc: gdb-patches@sourceware.org References: <1270936677-26654-1-git-send-email-vapier@gentoo.org> <20100412152413.GV19194@adacore.com> In-Reply-To: <20100412152413.GV19194@adacore.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1471387.f6R32l2lhb"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201004121150.49169.vapier@gentoo.org> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00360.txt.bz2 --nextPart1471387.f6R32l2lhb Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 2090 On Monday 12 April 2010 11:24:13 Joel Brobecker wrote: > > diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c > > index 643ce34..18987f9 100644 > > --- a/sim/common/dv-sockser.c > > +++ b/sim/common/dv-sockser.c > > @@ -129,7 +129,8 @@ dv_sockser_init (SIM_DESC sd) > >=20 > > struct sockaddr_in sockaddr; > > char hostname[100]; > > const char *port_str; > >=20 > > - int tmp,port; > > + unsigned tmp; > > + int port; >=20 > I'm not sure I agree on this one. "tmp" is used to store the result of > a subtraction of 2 pointers. IIRC, the exact type returned is ptrdiff_t, > which is a signed value... true, but the math should never yield a negative value. the compare is=20 between a base pointer and a pointer returned from strchr() on the base=20 pointer. so the value should always be >=3D 0 and it should always fit in= =20 32bits. > > hw_port_encode (struct hw *me, > >=20=20 > > int port_number, > > char *buf, > >=20 > > - int sizeof_buf, > > + unsigned sizeof_buf, > >=20 > > port_direction direction) >=20 > Would type size_t work, in this case? size_t would be usable in pretty much all the places i changed, but i=20 consciously did not pick that because "unsigned" is the current convention,= =20 both with local vars and function arguments. i didnt want to desync the ty= pe=20 conventions where some used size_t and some used unsigned especially since= =20 they're different sizes on 64bit systems. i certainly wouldnt be opposed to someone mass converting the source to=20 size_t, but i dont think i'm going to volunteer for that ;) > > @@ -583,7 +583,7 @@ hw_add_range_array_property (struct hw *me, > >=20 > > * sizeof (unsigned_cell)); > >=20=20=20=20 > > unsigned_cell *cells =3D hw_zalloc (me, sizeof_cells); > > unsigned_cell *cell; > >=20 > > - int i; > > + unsigned i; >=20 > I am not sure about this one either. Can you try changing the type > of parameter nr_ranges to int? It looks like the only usage of this > function is in hw-tree, and the variable used is actually an int... i'll check these -mike --nextPart1471387.f6R32l2lhb Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. Content-length: 836 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iQIcBAABAgAGBQJLw0FZAAoJEEFjO5/oN/WBT04P/jMg7o77syWiv4iORSIp5pYj 1tRWaTJFTh0aZPgnIGa4N6Qosd3duxjs2j1SYXfSgjyOy6gDS/XcvVMXE3TA41C4 QBe+E1DrXvEQuV+CSm847o03Mq7aQN7Uwada/J0M81wThUmPCIIBMDOGODa9TN8f 5xiQNo2s6rZcaXLc6Jw592RoyfBA1faYNo0upcmdvRQYK/9Iww1n/bel+yzJ+Obj NbmNUGwyHfqpGVl8ia3GueZZxf+AgsvhCXs3d1FfRzZ5EDpMFa//YeOodijrpEPt a6xQ+VL5Y+5apu6ZJQyNtqiqOzxbIYH09RslsuEtChWIxeaKOHIRbLWgoj5URkWQ AgLfw8kkUmjPvSrZ4n608gAOZBXsgHJbkaE9Qwnt8R9a0PoSsXKocbvQxoSvHhM9 oBfa8VzUS/H2yqhvvQWoWLji8qNPG9trR/EpHHBlP/VrkF6AKmaVCUE2deRQm/24 p0WNV7gDQu3svgAgkFCmrVVFeDtGbtFI+wYWPwJjbaF9KWfgooIDrK5M8tqHUU3u /G88Cb1WMTelC8pXH31QzOnANek5dd3h/gVu315WFXXU/gfHT3VHO8zZyKPzDYRE LbqiCWDL+U7QIcxYLEX/Uzo1DHWosTAMRBz+2dUFCD8iCKBF7fkqjjeFFyWR630A 4oHos2bzNXyXolHr8wJj =uzE7 -----END PGP SIGNATURE----- --nextPart1471387.f6R32l2lhb--