From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] sim: tweak signed to unsigned local vars
Date: Sat, 10 Apr 2010 21:58:00 -0000 [thread overview]
Message-ID: <1270936677-26654-1-git-send-email-vapier@gentoo.org> (raw)
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
next reply other threads:[~2010-04-10 21:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-10 21:58 Mike Frysinger [this message]
2010-04-12 15:24 ` Joel Brobecker
2010-04-12 15:52 ` Mike Frysinger
2010-04-12 16:06 ` Joel Brobecker
2010-04-12 18:30 ` Mike Frysinger
2010-04-12 19:59 ` Joel Brobecker
2010-04-12 18:45 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1270936677-26654-1-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox