summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-04-10 16:52:32 -0400
committerMike Frysinger <vapier@gentoo.org>2022-11-11 01:44:17 +0700
commitbb386bf4b7d2c6558ee476de3a7f9e5c4270bd98 (patch)
tree7f6100a4ef2fdc184262316bd57c5ffb1d6ecef0
parent61669e1068e518cab2a72768adb1fc034e0c81cf (diff)
downloadbinutils-gdb-bb386bf4b7d2c6558ee476de3a7f9e5c4270bd98.tar.gz
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.
-rw-r--r--sim/common/dv-sockser.c3
-rw-r--r--sim/common/hw-ports.c2
-rw-r--r--sim/common/hw-ports.h2
-rw-r--r--sim/common/hw-properties.c10
-rw-r--r--sim/common/hw-tree.c22
-rw-r--r--sim/common/sim-core.c4
6 files changed, 22 insertions, 21 deletions
diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index 812acf911c4..13902aae99e 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -101,7 +101,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 cb412edd33d..7734bae1f90 100644
--- a/sim/common/hw-ports.c
+++ b/sim/common/hw-ports.c
@@ -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;
diff --git a/sim/common/hw-ports.h b/sim/common/hw-ports.h
index bab625095f5..5295f76baa2 100644
--- a/sim/common/hw-ports.h
+++ b/sim/common/hw-ports.h
@@ -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);
diff --git a/sim/common/hw-properties.c b/sim/common/hw-properties.c
index 3d2b5cdda7a..04732e507b8 100644
--- a/sim/common/hw-properties.c
+++ b/sim/common/hw-properties.c
@@ -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;
diff --git a/sim/common/hw-tree.c b/sim/common/hw-tree.c
index 8bb5ac77545..7b1abdecfee 100644
--- a/sim/common/hw-tree.c
+++ b/sim/common/hw-tree.c
@@ -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++)
diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
index fab8f101595..d726e031fea 100644
--- a/sim/common/sim-core.c
+++ b/sim/common/sim-core.c
@@ -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