From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13765 invoked by alias); 12 Apr 2010 15:24:37 -0000 Received: (qmail 13752 invoked by uid 22791); 12 Apr 2010 15:24:35 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Apr 2010 15:24:29 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A77C72BAB85; Mon, 12 Apr 2010 11:24:27 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id E-r47TiTsLfk; Mon, 12 Apr 2010 11:24:27 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 6FCCE2BAB88; Mon, 12 Apr 2010 11:24:27 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 42EEAF58C2; Mon, 12 Apr 2010 08:24:13 -0700 (PDT) Date: Mon, 12 Apr 2010 15:24:00 -0000 From: Joel Brobecker To: Mike Frysinger Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] sim: tweak signed to unsigned local vars Message-ID: <20100412152413.GV19194@adacore.com> References: <1270936677-26654-1-git-send-email-vapier@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1270936677-26654-1-git-send-email-vapier@gentoo.org> User-Agent: Mutt/1.5.20 (2009-06-14) 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/msg00359.txt.bz2 > 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) > struct sockaddr_in sockaddr; > char hostname[100]; > const char *port_str; > - int tmp,port; > + unsigned tmp; > + int port; 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... > hw_port_encode (struct hw *me, > int port_number, > char *buf, > - int sizeof_buf, > + unsigned sizeof_buf, > port_direction direction) Would type size_t work, in this case? > - int sizeof_buf, > + unsigned sizeof_buf, Same here? > @@ -583,7 +583,7 @@ hw_add_range_array_property (struct hw *me, > * sizeof (unsigned_cell)); > unsigned_cell *cells = hw_zalloc (me, sizeof_cells); > unsigned_cell *cell; > - int i; > + unsigned i; 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... > @@ -676,7 +676,7 @@ hw_add_reg_array_property (struct hw *me, > * sizeof (unsigned_cell)); > unsigned_cell *cells = hw_zalloc (me, sizeof_cells); > unsigned_cell *cell; > - int i; > + unsigned i; Same here. > @@ -776,8 +776,8 @@ hw_add_string_array_property (struct hw *me, > const string_property_spec *strings, > unsigned nr_strings) Same for nr_strings. > - int sizeof_array; > - int string_nr; > + unsigned sizeof_array; > + unsigned string_nr; Once nr_strings is changed to int, we should no longer need to change string_nr to unsigned. Would type size_t for sizeof_array work in your case? It seems that the use of int or unsigned is a little random for this type of argument (check the use of the hw_add_property function, sometimes we pass an int, sometimes we pass an unsigned). > @@ -840,7 +840,7 @@ hw_find_string_array_property (struct hw *me, > ASSERT (((char*)node->array)[node->sizeof_array - 1] == '\0'); > { > const char *chp = node->array; > - int nr_entries = 0; > + unsigned nr_entries = 0; Same as above. > @@ -1115,7 +1115,7 @@ print_properties (struct hw *me, > if ((property->sizeof_array % sizeof (signed_cell)) == 0) > { > unsigned_cell *w = (unsigned_cell*) property->array; > - int cell_nr; > + unsigned cell_nr; Use size_t? -- Joel