]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: tweak signed to unsigned local vars
authorMike Frysinger <vapier@gentoo.org>
Sat, 10 Apr 2010 20:52:32 +0000 (16:52 -0400)
committerMike Frysinger <vapier@gentoo.org>
Mon, 1 Jan 2024 23:23:25 +0000 (18:23 -0500)
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
sim/common/hw-ports.c
sim/common/hw-ports.h
sim/common/hw-properties.c
sim/common/hw-tree.c
sim/common/sim-core.c

index 698cab839209db5d7977a8963f084d20a7d8d1f4..78ae073c31300cc6220b992181a590316b356dc4 100644 (file)
@@ -99,7 +99,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)
index 226b47ebb0e26e0d355e39cafd21b54004abde39..44474bac4833ffe94716e188407f2bb91a708d59 100644 (file)
@@ -286,7 +286,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;
index 42c144c17ea84412dd468b341983c79983572758..59d9cc848648e8a4a90b04ce093567abd3888a1e 100644 (file)
@@ -122,7 +122,7 @@ int hw_port_encode
 (struct hw *me,
  int port_number,
  char *buf,
int sizeof_buf,
unsigned sizeof_buf,
  port_direction direction);
 
 
index 52aad17e0c40f7f6d53ceba921b905d196155d28..f6e53d4d0535f90c982dd0c9008e8612a4b4825e 100644 (file)
@@ -578,7 +578,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;
@@ -671,7 +671,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;
@@ -771,8 +771,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)
@@ -835,7 +835,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;
index a993732719a7b36bb15b2533f6614ca104b50fb7..6ee1e22799b20132a884ce96012009d7e85f2ecb 100644 (file)
@@ -81,7 +81,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] != ':'
@@ -445,14 +445,14 @@ skip_token (const char *chp)
 
 /* count the number of entries */
 
-static int
+static unsigned
 count_entries (struct hw *current,
               const char *property_name,
               const char *property_value,
-              int modulo)
+              unsigned modulo)
 {
   const char *chp = property_value;
-  int nr_entries = 0;
+  unsigned nr_entries = 0;
   while (*chp != '\0')
     {
       nr_entries += 1;
@@ -530,8 +530,8 @@ parse_reg_property (struct hw *current,
                    const char *property_name,
                    const char *property_value)
 {
-  int nr_regs;
-  int reg_nr;
+  unsigned nr_regs;
+  unsigned reg_nr;
   reg_property_spec *regs;
   const char *chp;
 
@@ -566,8 +566,8 @@ parse_ranges_property (struct hw *current,
                       const char *property_name,
                       const char *property_value)
 {
-  int nr_ranges;
-  int range_nr;
+  unsigned nr_ranges;
+  unsigned range_nr;
   range_property_spec *ranges;
   const char *chp;
 
@@ -646,8 +646,8 @@ parse_string_property (struct hw *current,
 {
   char **strings;
   const char *chp;
-  int nr_strings;
-  int approx_nr_strings;
+  unsigned nr_strings;
+  unsigned approx_nr_strings;
 
   /* get an estimate as to the number of strings by counting double
      quotes */
@@ -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++)
index 5779da96281cd0edda30a907dd29809b4d35998f..8c81cb03e2da405df00c6c1d649b14a62d1e4d87 100644 (file)
@@ -540,7 +540,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 the access was initiated by a cpu, pass it down so errors can
@@ -598,7 +598,7 @@ sim_core_write_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 the access was initiated by a cpu, pass it down so errors can