Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] sim: constify sim_write source buffer
@ 2010-04-10 21:58 Mike Frysinger
  2010-04-13 15:35 ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2010-04-10 21:58 UTC (permalink / raw)
  To: gdb-patches

Most the sim write functions declare their source buffer const because
they only ever read from it.  The global sim_write() function does not
follow this convention though which causes some warnings when trying to
pass it const strings or buffers.

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

	* remote-sim.h (sim_write): Add const to buf arg.

sim/common/:
2010-04-10  Mike Frysinger  <vapier@gentoo.org>

	* sim-hrw.c (sim_write): Add const to buf arg.
	* sim-utils.h (sim_write_fn): Likewise.

 include/gdb/remote-sim.h |    2 +-
 sim/common/sim-hrw.c     |    2 +-
 sim/common/sim-utils.h   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/gdb/remote-sim.h b/include/gdb/remote-sim.h
index cfb1c11..37f029a 100644
--- a/include/gdb/remote-sim.h
+++ b/include/gdb/remote-sim.h
@@ -175,7 +175,7 @@ int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
    memory. Store bytes starting at virtual address MEM. Result is
    number of bytes write, or zero if error.  */
 
-int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
+int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, const unsigned char *buf, int length));
 
 
 /* Fetch register REGNO storing its raw (target endian) value in the
diff --git a/sim/common/sim-hrw.c b/sim/common/sim-hrw.c
index e76a196..cedae87 100644
--- a/sim/common/sim-hrw.c
+++ b/sim/common/sim-hrw.c
@@ -32,7 +32,7 @@ sim_read (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
 }
 
 int
-sim_write (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
+sim_write (SIM_DESC sd, SIM_ADDR mem, const unsigned char *buf, int length)
 {
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
   return sim_core_write_buffer (sd, NULL, write_map,
diff --git a/sim/common/sim-utils.h b/sim/common/sim-utils.h
index 75d2fb4..e3ff63a 100644
--- a/sim/common/sim-utils.h
+++ b/sim/common/sim-utils.h
@@ -63,7 +63,7 @@ SIM_RC sim_analyze_program (SIM_DESC sd, char *prog_name,
    This is still accommodated for backward compatibility reasons. */
 
 typedef int sim_write_fn PARAMS ((SIM_DESC sd, SIM_ADDR mem,
-				      unsigned char *buf, int length));
+				      const unsigned char *buf, int length));
 struct bfd *sim_load_file (SIM_DESC sd, const char *myname,
 			   host_callback *callback, char *prog,
 			   struct bfd *prog_bfd, int verbose_p,
-- 
1.7.0.2


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH] sim: constify sim_write source buffer
@ 2010-04-13 23:25 Sandra Loosemore
  2010-04-14  0:39 ` Mike Frysinger
  0 siblings, 1 reply; 6+ messages in thread
From: Sandra Loosemore @ 2010-04-13 23:25 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

FYI, this patch:

2010-04-13  Mike Frysinger  <vapier@gentoo.org>

	* remote-sim.h (sim_write): Add const to buf arg.

caused the ARM simulator to fail to build.  See sim/arm/wrapper.c:158:

int
sim_write (sd, addr, buffer, size)
      SIM_DESC sd ATTRIBUTE_UNUSED;
      SIM_ADDR addr;
      unsigned char * buffer;
      int size;

The obvious patch makes it build, at least.

-Sandra


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-04-14  6:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-10 21:58 [PATCH] sim: constify sim_write source buffer Mike Frysinger
2010-04-13 15:35 ` Joel Brobecker
2010-04-13 20:39   ` [PATCH] sim: drop PARAMS Mike Frysinger
2010-04-13 23:25 [PATCH] sim: constify sim_write source buffer Sandra Loosemore
2010-04-14  0:39 ` Mike Frysinger
2010-04-14  6:03   ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox