Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] sim: update device_error() prototype
@ 2010-03-29 20:39 Mike Frysinger
  2010-03-29 21:32 ` Eli Zaretskii
  2010-03-30 16:51 ` Tom Tromey
  0 siblings, 2 replies; 5+ messages in thread
From: Mike Frysinger @ 2010-03-29 20:39 UTC (permalink / raw)
  To: gdb-patches

The device_error() takes a printf style string, so update the prototype
accordingly.  The message should be const and it should use an attribute.
This fixes gcc warnings like:

sim-core.c: In function 'sim_core_map_attach':
sim-core.c:200: warning: passing argument 2 of 'device_error' discards qualifiers from pointer target type
sim-core.c:237: warning: passing argument 2 of 'device_error' discards qualifiers from pointer target type
sim-core.c: In function 'sim_core_attach':
sim-core.c:304: warning: passing argument 2 of 'device_error' discards qualifiers from pointer target type
sim-core.c:314: warning: passing argument 2 of 'device_error' discards qualifiers from pointer target type
sim-core.c:335: warning: passing argument 2 of 'device_error' discards qualifiers from pointer target type
sim-core.c:348: warning: passing argument 2 of 'device_error' discards qualifiers from pointer target type

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
common/:
2010-03-29  Mike Frysinger  <vapier@gentoo.org>

	* sim-core.h (device_error): Add const to message, and add printf
	format attribute.

cris/:
2010-03-29  Mike Frysinger  <vapier@gentoo.org>

	* devices.c (device_error): Add const to message.

frv/:
2010-03-29  Mike Frysinger  <vapier@gentoo.org>

	* devices.c (device_error): Add const to message.

m32r/:
2010-03-29  Mike Frysinger  <vapier@gentoo.org>

	* devices.c (device_error): Add const to message.

 sim/common/sim-core.h |    2 +-
 sim/cris/devices.c    |    2 +-
 sim/frv/devices.c     |    2 +-
 sim/m32r/devices.c    |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sim/common/sim-core.h b/sim/common/sim-core.h
index 3fac627..696511c 100644
--- a/sim/common/sim-core.h
+++ b/sim/common/sim-core.h
@@ -344,7 +344,7 @@ DECLARE_SIM_CORE_READ_N(misaligned,7,8)
 #if (WITH_DEVICES)
 /* TODO: create sim/common/device.h */
 /* These are defined with each particular cpu.  */
-void device_error (device *me, char* message, ...);
+void device_error (device *me, const char *message, ...) __attribute__((format (printf, 2, 3)));
 int device_io_read_buffer(device *me, void *dest, int space, address_word addr, unsigned nr_bytes, SIM_DESC sd, sim_cpu *processor, sim_cia cia);
 int device_io_write_buffer(device *me, const void *source, int space, address_word addr, unsigned nr_bytes, SIM_DESC sd, sim_cpu *processor, sim_cia cia);
 #endif
diff --git a/sim/cris/devices.c b/sim/cris/devices.c
index 7218c66..50032a6 100644
--- a/sim/cris/devices.c
+++ b/sim/cris/devices.c
@@ -34,7 +34,7 @@ struct _device { char dummy; } cris_devices;
 
 void
 device_error (device *me ATTRIBUTE_UNUSED,
-	      char *message ATTRIBUTE_UNUSED,
+	      const char *message ATTRIBUTE_UNUSED,
 	      ...)
 {
   abort ();
diff --git a/sim/frv/devices.c b/sim/frv/devices.c
index 3c028c0..9b0819f 100644
--- a/sim/frv/devices.c
+++ b/sim/frv/devices.c
@@ -93,4 +93,4 @@ device_io_write_buffer (device *me, const void *source, int space,
   return nr_bytes;
 }
 
-void device_error (device *me, char* message, ...) {}
+void device_error (device *me, const char *message, ...) {}
diff --git a/sim/m32r/devices.c b/sim/m32r/devices.c
index cc39d5d..4442f11 100644
--- a/sim/m32r/devices.c
+++ b/sim/m32r/devices.c
@@ -102,6 +102,6 @@ device_io_write_buffer (device *me, const void *source, int space,
 }
 
 void
-device_error (device *me, char *message, ...)
+device_error (device *me, const char *message, ...)
 {
 }
-- 
1.7.0.2


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

* Re: [PATCH] sim: update device_error() prototype
  2010-03-29 20:39 [PATCH] sim: update device_error() prototype Mike Frysinger
@ 2010-03-29 21:32 ` Eli Zaretskii
  2010-03-29 21:59   ` Mike Frysinger
  2010-03-30 16:16   ` Tom Tromey
  2010-03-30 16:51 ` Tom Tromey
  1 sibling, 2 replies; 5+ messages in thread
From: Eli Zaretskii @ 2010-03-29 21:32 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

> From: Mike Frysinger <vapier@gentoo.org>
> Date: Mon, 29 Mar 2010 16:39:06 -0400
> 
> -void device_error (device *me, char* message, ...);
> +void device_error (device *me, const char *message, ...) __attribute__((format (printf, 2, 3)));

Is this always compiled only with GCC?  __attribute__ is a GCC
specific feature, AFAIK.


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

* Re: [PATCH] sim: update device_error() prototype
  2010-03-29 21:32 ` Eli Zaretskii
@ 2010-03-29 21:59   ` Mike Frysinger
  2010-03-30 16:16   ` Tom Tromey
  1 sibling, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2010-03-29 21:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 751 bytes --]

On Monday 29 March 2010 17:32:33 Eli Zaretskii wrote:
> > From: Mike Frysinger <vapier@gentoo.org>
> > Date: Mon, 29 Mar 2010 16:39:06 -0400
> > 
> > -void device_error (device *me, char* message, ...);
> > +void device_error (device *me, const char *message, ...)
> > __attribute__((format (printf, 2, 3)));
> 
> Is this always compiled only with GCC?  __attribute__ is a GCC
> specific feature, AFAIK.

i didnt worry about it because a lot of places in sim/common/ are using the 
printf format attribute unconditionally.  if this really was a problem for 
people, then they'd already be broken and have more work to clean up.  i'm 
assuming this isnt a realistic problem because it hasnt been reported and/or a 
patch posted.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] sim: update device_error() prototype
  2010-03-29 21:32 ` Eli Zaretskii
  2010-03-29 21:59   ` Mike Frysinger
@ 2010-03-30 16:16   ` Tom Tromey
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2010-03-30 16:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Mike Frysinger, gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> From: Mike Frysinger <vapier@gentoo.org>
>> Date: Mon, 29 Mar 2010 16:39:06 -0400
>> 
>> -void device_error (device *me, char* message, ...);
>> +void device_error (device *me, const char *message, ...) __attribute__((format (printf, 2, 3)));

Eli> Is this always compiled only with GCC?  __attribute__ is a GCC
Eli> specific feature, AFAIK.

sim-basics.h defines __attribute__ if not using gcc.  This is not really
an approach I would recommend, because different versions of gcc have
different attributes, but it is ok if you stick to a minimal subset of
attributes.

Tom


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

* Re: [PATCH] sim: update device_error() prototype
  2010-03-29 20:39 [PATCH] sim: update device_error() prototype Mike Frysinger
  2010-03-29 21:32 ` Eli Zaretskii
@ 2010-03-30 16:51 ` Tom Tromey
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2010-03-30 16:51 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

>>>>> "Mike" == Mike Frysinger <vapier@gentoo.org> writes:

Mike> 2010-03-29  Mike Frysinger  <vapier@gentoo.org>
Mike> 	* sim-core.h (device_error): Add const to message, and add printf
Mike> 	format attribute.

Mike> cris/:
Mike> 2010-03-29  Mike Frysinger  <vapier@gentoo.org>
Mike> 	* devices.c (device_error): Add const to message.

Mike> frv/:
Mike> 2010-03-29  Mike Frysinger  <vapier@gentoo.org>
Mike> 	* devices.c (device_error): Add const to message.

Mike> m32r/:
Mike> 2010-03-29  Mike Frysinger  <vapier@gentoo.org>
Mike> 	* devices.c (device_error): Add const to message.

This seems reasonable to me.  Ok.

Tom


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

end of thread, other threads:[~2010-03-30 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-29 20:39 [PATCH] sim: update device_error() prototype Mike Frysinger
2010-03-29 21:32 ` Eli Zaretskii
2010-03-29 21:59   ` Mike Frysinger
2010-03-30 16:16   ` Tom Tromey
2010-03-30 16:51 ` Tom Tromey

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