This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] sim: tweak signed to unsigned local vars


This tweaks a lot of hardware code to use "unsigned" instead of "int" to
fix gcc warnings about signed/unsigned comparisons.  In these cases, the
code is already working with unsigned variables, so there shouldn't be a
problem converting the local variables from "int".

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
2010-04-10  Mike Frysinger  <vapier@gentoo.org>

	* dv-sockser.c (dv_sockser_init): Change local tmp var to unsigned.
	* hw-ports.c, hw-ports.h (hw_port_encode): Change sizeof_buf arg to
	unsigned.
	* hw-properties.c (hw_add_range_array_property): Change local i var
	to unsigned.
	(hw_add_reg_array_property): Likewise.
	(hw_add_string_array_property): Change local vars sizeof_array and
	string_nr to unsigned.
	(hw_find_string_array_property): Change local vars nr_entries to
	unsigned.
	* hw-tree.c (split_device_specifier): Change local len var to
	unsigned.
	(print_properties): Change local cell_nr var to unsigned.
	* sim-core.c (sim_core_read_buffer): Change local nr_bytes var to
	unsigned.
	(sim_core_write_buffer): Likewise.

 sim/common/dv-sockser.c    |    3 ++-
 sim/common/hw-ports.c      |    2 +-
 sim/common/hw-ports.h      |    2 +-
 sim/common/hw-properties.c |   10 +++++-----
 sim/common/hw-tree.c       |    4 ++--
 sim/common/sim-core.c      |    4 ++--
 6 files changed, 13 insertions(+), 12 deletions(-)

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;
 
   if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT
       || sockser_addr == NULL)
diff --git a/sim/common/hw-ports.c b/sim/common/hw-ports.c
index 8f88cb3..5adb072 100644
--- a/sim/common/hw-ports.c
+++ b/sim/common/hw-ports.c
@@ -292,7 +292,7 @@ int
 hw_port_encode (struct hw *me,
 		int port_number,
 		char *buf,
-		int sizeof_buf,
+		unsigned sizeof_buf,
 		port_direction direction)
 {
   const struct hw_port_descriptor *ports = NULL;
diff --git a/sim/common/hw-ports.h b/sim/common/hw-ports.h
index 01a4dcd..f6c8e6b 100644
--- a/sim/common/hw-ports.h
+++ b/sim/common/hw-ports.h
@@ -121,7 +121,7 @@ int hw_port_encode
 (struct hw *me,
  int port_number,
  char *buf,
- int sizeof_buf,
+ unsigned sizeof_buf,
  port_direction direction);
  
 
diff --git a/sim/common/hw-properties.c b/sim/common/hw-properties.c
index 018a84c..d1d6dc5 100644
--- a/sim/common/hw-properties.c
+++ b/sim/common/hw-properties.c
@@ -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;
   
   /* copy the property elements over */
   cell = cells;
@@ -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;
   
   /* copy the property elements over */
   cell = cells;
@@ -776,8 +776,8 @@ hw_add_string_array_property (struct hw *me,
 			      const string_property_spec *strings,
 			      unsigned nr_strings)
 {
-  int sizeof_array;
-  int string_nr;
+  unsigned sizeof_array;
+  unsigned string_nr;
   char *array;
   char *chp;
   if (nr_strings == 0)
@@ -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;
 	/* count the number of strings, keeping an eye out for the one
 	   we're looking for */
 	*string = chp;
diff --git a/sim/common/hw-tree.c b/sim/common/hw-tree.c
index d3530d0..7276b7c 100644
--- a/sim/common/hw-tree.c
+++ b/sim/common/hw-tree.c
@@ -87,7 +87,7 @@ split_device_specifier (struct hw *current,
     {
       struct hw *aliases = hw_tree_find_device (current, "/aliases");
       char alias[32];
-      int len = 0;
+      unsigned len = 0;
       while (device_specifier[len] != '\0'
 	     && device_specifier[len] != '/'
 	     && device_specifier[len] != ':'
@@ -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;
 		    for (cell_nr = 0;
 			 cell_nr < (property->sizeof_array / sizeof (unsigned_cell));
 			 cell_nr++)
diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
index 5476ead..fd982bb 100644
--- a/sim/common/sim-core.c
+++ b/sim/common/sim-core.c
@@ -547,7 +547,7 @@ sim_core_read_buffer (SIM_DESC sd,
 #if (WITH_HW)
     if (mapping->device != NULL)
       {
-	int nr_bytes = len - count;
+	unsigned nr_bytes = len - count;
 	if (raddr + nr_bytes - 1> mapping->bound)
 	  nr_bytes = mapping->bound - raddr + 1;
 	if (sim_hw_io_read_buffer (sd, mapping->device,
@@ -615,7 +615,7 @@ sim_core_write_buffer (SIM_DESC sd,
       if (WITH_CALLBACK_MEMORY
 	  && mapping->device != NULL)
 	{
-	  int nr_bytes = len - count;
+	  unsigned nr_bytes = len - count;
 	  if (raddr + nr_bytes - 1 > mapping->bound)
 	    nr_bytes = mapping->bound - raddr + 1;
 	  if (sim_hw_io_write_buffer (sd, mapping->device,
-- 
1.7.0.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]