qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] mips_fulong2e: Detect format errors for function prom_set
@ 2010-09-11  6:46 Stefan Weil
  2010-09-11  6:46 ` [Qemu-devel] [PATCH] mips_malta: " Stefan Weil
  2010-09-20 19:03 ` [Qemu-devel] [PATCH] mips_fulong2e: " Blue Swirl
  0 siblings, 2 replies; 19+ messages in thread
From: Stefan Weil @ 2010-09-11  6:46 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Aurelien Jarno

Add the necessary gcc attribute and fix the detected errors.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/mips_fulong2e.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index cbe7156..2ef5070 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -77,6 +77,8 @@ static struct _loaderparams {
 } loaderparams;
 
 static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
+    __attribute__ ((format (gnu_printf, 3, 4)));
+static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
 {
     va_list ap;
     int32_t table_addr;
@@ -141,13 +143,13 @@ static int64_t load_kernel (CPUState *env)
     prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
     prom_buf = qemu_malloc(prom_size);
 
-    prom_set(prom_buf, index++, loaderparams.kernel_filename);
+    prom_set(prom_buf, index++, "%s", loaderparams.kernel_filename);
     if (initrd_size > 0) {
-        prom_set(prom_buf, index++, "rd_start=0x" PRIx64 " rd_size=%li %s",
+        prom_set(prom_buf, index++, "rd_start=0x%" PRIx64 " rd_size=%li %s",
                  cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size,
                  loaderparams.kernel_cmdline);
     } else {
-        prom_set(prom_buf, index++, loaderparams.kernel_cmdline);
+        prom_set(prom_buf, index++, "%s", loaderparams.kernel_cmdline);
     }
 
     /* Setup minimum environment variables */
-- 
1.7.0.4

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

* [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set
  2010-09-11  6:46 [Qemu-devel] [PATCH] mips_fulong2e: Detect format errors for function prom_set Stefan Weil
@ 2010-09-11  6:46 ` Stefan Weil
  2010-09-13 20:02   ` [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf Stefan Weil
                     ` (2 more replies)
  2010-09-20 19:03 ` [Qemu-devel] [PATCH] mips_fulong2e: " Blue Swirl
  1 sibling, 3 replies; 19+ messages in thread
From: Stefan Weil @ 2010-09-11  6:46 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Aurelien Jarno

Add the necessary gcc attribute and fix the detected errors.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/mips_malta.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index a458c97..deee273 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -684,6 +684,8 @@ static void write_bootloader (CPUState *env, uint8_t *base,
 }
 
 static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
+    __attribute__ ((format (gnu_printf, 3, 4)));
+static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
 {
     va_list ap;
     int32_t table_addr;
@@ -750,13 +752,13 @@ static int64_t load_kernel(int big_endian)
     prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
     prom_buf = qemu_malloc(prom_size);
 
-    prom_set(prom_buf, prom_index++, loaderparams.kernel_filename);
+    prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
     if (initrd_size > 0) {
         prom_set(prom_buf, prom_index++, "rd_start=0x%" PRIx64 " rd_size=%li %s",
                  cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size,
                  loaderparams.kernel_cmdline);
     } else {
-        prom_set(prom_buf, prom_index++, loaderparams.kernel_cmdline);
+        prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline);
     }
 
     prom_set(prom_buf, prom_index++, "memsize");
-- 
1.7.0.4

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

* [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf
  2010-09-11  6:46 ` [Qemu-devel] [PATCH] mips_malta: " Stefan Weil
@ 2010-09-13 20:02   ` Stefan Weil
  2010-09-20 19:18     ` Blue Swirl
  2010-09-13 20:02   ` [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf Stefan Weil
  2010-09-20 19:04   ` [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set Blue Swirl
  2 siblings, 1 reply; 19+ messages in thread
From: Stefan Weil @ 2010-09-13 20:02 UTC (permalink / raw)
  To: QEMU Developers

Since version 4.4.x, gcc supports additional format attributes.
    __attribute__ ((format (gnu_printf, 1, 2)))
should be used instead of
    __attribute__ ((format (printf, 1, 2))
because QEMU always uses standard format strings (even with mingw32).

For older compilers, we simply define gnu_printf = printf,
so they work with the new format attribute, too.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 configure |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 4061cb7..1300879 100755
--- a/configure
+++ b/configure
@@ -148,6 +148,17 @@ for flag in $gcc_flags; do
     fi
 done
 
+# Check gnu_printf (supported by gcc >= 4.4.x).
+cat > $TMPC << EOF
+static void test(const char *format, ...)
+    __attribute__ ((format (gnu_printf, 1, 2)));
+static void test(const char *format, ...) {}
+int main(void) { test("\n"); return 0; }
+EOF
+if ! compile_prog "-Werror" ""; then
+    QEMU_CFLAGS="-Dgnu_printf=printf $QEMU_CFLAGS"
+fi
+
 # check that the C compiler works.
 cat > $TMPC <<EOF
 int main(void) {}
-- 
1.7.1

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

* [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf
  2010-09-11  6:46 ` [Qemu-devel] [PATCH] mips_malta: " Stefan Weil
  2010-09-13 20:02   ` [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf Stefan Weil
@ 2010-09-13 20:02   ` Stefan Weil
  2010-09-20 18:53     ` Blue Swirl
  2010-09-20 19:04   ` [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set Blue Swirl
  2 siblings, 1 reply; 19+ messages in thread
From: Stefan Weil @ 2010-09-13 20:02 UTC (permalink / raw)
  To: QEMU Developers

Since version 4.4.x, gcc supports additional format attributes.
    __attribute__ ((format (gnu_printf, 1, 2)))
should be used instead of
    __attribute__ ((format (printf, 1, 2))
because QEMU always uses standard format strings (even with mingw32).

The patch replaces format attribute printf / __printf__ by gnu_printf.

It also removes an #ifdef __GNUC__ (not needed as long as we compile
with gcc, and for non-gcc compilers we need more changes than this).

The gcc documentation uses format (not __format__), the majority in
QEMU uses this shorter form, too. Therefore the patch also replaces
__format__ by format.

Spacing was unified (again as in the gcc documentation).

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 audio/audio.h      |    5 +----
 audio/audio_int.h  |    4 ++--
 bsd-user/qemu.h    |    2 +-
 cpu-all.h          |    2 +-
 darwin-user/qemu.h |    2 +-
 hw/xen_backend.h   |    2 +-
 linux-user/qemu.h  |    2 +-
 monitor.h          |    2 +-
 qemu-common.h      |    2 +-
 qemu-error.h       |    8 +++++---
 qerror.h           |    2 +-
 qjson.h            |    2 +-
 12 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/audio/audio.h b/audio/audio.h
index 454ade2..4439b82 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -88,10 +88,7 @@ typedef struct QEMUAudioTimeStamp {
 
 void AUD_vlog (const char *cap, const char *fmt, va_list ap);
 void AUD_log (const char *cap, const char *fmt, ...)
-#ifdef __GNUC__
-    __attribute__ ((__format__ (__printf__, 2, 3)))
-#endif
-    ;
+    __attribute__ ((format (gnu_printf, 2, 3)));
 
 void AUD_help (void);
 void AUD_register_card (const char *name, QEMUSoundCard *card);
diff --git a/audio/audio_int.h b/audio/audio_int.h
index 06e313f..f6a77ad 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -237,8 +237,8 @@ static inline int audio_ring_dist (int dst, int src, int len)
 }
 
 #if defined __GNUC__
-#define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2)))
-#define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (__printf__, n, m)))
+#define GCC_ATTR __attribute__ ((__unused__, format (gnu_printf, 1, 2)))
+#define GCC_FMT_ATTR(n, m) __attribute__ ((format (gnu_printf, n, m)))
 #else
 #define GCC_ATTR /**/
 #define GCC_FMT_ATTR(n, m)
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 554ff8b..34407aa 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -139,7 +139,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
 abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
                             abi_long arg2, abi_long arg3, abi_long arg4,
                             abi_long arg5, abi_long arg6);
-void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2)));
+void gemu_log(const char *fmt, ...) __attribute__((format (gnu_printf, 1, 2)));
 extern THREAD CPUState *thread_env;
 void cpu_loop(CPUState *env);
 char *target_strerror(int err);
diff --git a/cpu-all.h b/cpu-all.h
index 67a3266..183bb40 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -773,7 +773,7 @@ void cpu_dump_statistics (CPUState *env, FILE *f,
                           int flags);
 
 void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...)
-    __attribute__ ((__format__ (__printf__, 2, 3)));
+    __attribute__ ((format (gnu_printf, 2, 3)));
 extern CPUState *first_cpu;
 extern CPUState *cpu_single_env;
 
diff --git a/darwin-user/qemu.h b/darwin-user/qemu.h
index 462bbda..2df2bc9 100644
--- a/darwin-user/qemu.h
+++ b/darwin-user/qemu.h
@@ -99,7 +99,7 @@ int do_sigaction(int sig, const struct sigaction *act,
                  struct sigaction *oact);
 int do_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss);
 
-void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2)));
+void gemu_log(const char *fmt, ...) __attribute__((format (gnu_printf, 1, 2)));
 void qerror(const char *fmt, ...);
 
 void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags);
diff --git a/hw/xen_backend.h b/hw/xen_backend.h
index 292126d..5b78182 100644
--- a/hw/xen_backend.h
+++ b/hw/xen_backend.h
@@ -84,7 +84,7 @@ int xen_be_bind_evtchn(struct XenDevice *xendev);
 void xen_be_unbind_evtchn(struct XenDevice *xendev);
 int xen_be_send_notify(struct XenDevice *xendev);
 void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
-    __attribute__ ((format(printf, 3, 4)));
+    __attribute__ ((format (gnu_printf, 3, 4)));
 
 /* actual backend drivers */
 extern struct XenDevOps xen_console_ops;      /* xen_console.c     */
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 794fe49..779d892 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -186,7 +186,7 @@ void syscall_init(void);
 abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                     abi_long arg2, abi_long arg3, abi_long arg4,
                     abi_long arg5, abi_long arg6);
-void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2)));
+void gemu_log(const char *fmt, ...) __attribute__ ((format (gnu_printf, 1, 2)));
 extern THREAD CPUState *thread_env;
 void cpu_loop(CPUState *env);
 char *target_strerror(int err);
diff --git a/monitor.h b/monitor.h
index 38b22a4..d4c3872 100644
--- a/monitor.h
+++ b/monitor.h
@@ -51,7 +51,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname);
 
 void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap);
 void monitor_printf(Monitor *mon, const char *fmt, ...)
-    __attribute__ ((__format__ (__printf__, 2, 3)));
+    __attribute__ ((format (gnu_printf, 2, 3)));
 void monitor_print_filename(Monitor *mon, const char *filename);
 void monitor_flush(Monitor *mon);
 
diff --git a/qemu-common.h b/qemu-common.h
index dfd3dc0..956b545 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -181,7 +181,7 @@ int qemu_pipe(int pipefd[2]);
 /* Error handling.  */
 
 void QEMU_NORETURN hw_error(const char *fmt, ...)
-    __attribute__ ((__format__ (__printf__, 1, 2)));
+    __attribute__ ((format (gnu_printf, 1, 2)));
 
 /* IO callbacks.  */
 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
diff --git a/qemu-error.h b/qemu-error.h
index a45609f..25f2bfb 100644
--- a/qemu-error.h
+++ b/qemu-error.h
@@ -31,11 +31,13 @@ void loc_set_cmdline(char **argv, int idx, int cnt);
 void loc_set_file(const char *fname, int lno);
 
 void error_vprintf(const char *fmt, va_list ap);
-void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
+void error_printf(const char *fmt, ...)
+    __attribute__ ((format (gnu_printf, 1, 2)));
 void error_printf_unless_qmp(const char *fmt, ...)
-    __attribute__ ((format(printf, 1, 2)));
+    __attribute__ ((format (gnu_printf, 1, 2)));
 void error_print_loc(void);
 void error_set_progname(const char *argv0);
-void error_report(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
+void error_report(const char *fmt, ...)
+    __attribute__ ((format (gnu_printf, 1, 2)));
 
 #endif
diff --git a/qerror.h b/qerror.h
index 62802ea..fbabe89 100644
--- a/qerror.h
+++ b/qerror.h
@@ -39,7 +39,7 @@ QString *qerror_human(const QError *qerror);
 void qerror_print(QError *qerror);
 void qerror_report_internal(const char *file, int linenr, const char *func,
                             const char *fmt, ...)
-    __attribute__ ((format(printf, 4, 5)));
+    __attribute__ ((format (gnu_printf, 4, 5)));
 #define qerror_report(fmt, ...) \
     qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
 QError *qobject_to_qerror(const QObject *obj);
diff --git a/qjson.h b/qjson.h
index 7afec2e..b21423a 100644
--- a/qjson.h
+++ b/qjson.h
@@ -20,7 +20,7 @@
 
 QObject *qobject_from_json(const char *string);
 QObject *qobject_from_jsonf(const char *string, ...)
-    __attribute__((__format__ (__printf__, 1, 2)));
+    __attribute__((format (gnu_printf, 1, 2)));
 QObject *qobject_from_jsonv(const char *string, va_list *ap);
 
 QString *qobject_to_json(const QObject *obj);
-- 
1.7.1

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

* Re: [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf
  2010-09-13 20:02   ` [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf Stefan Weil
@ 2010-09-20 18:53     ` Blue Swirl
  0 siblings, 0 replies; 19+ messages in thread
From: Blue Swirl @ 2010-09-20 18:53 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

On Mon, Sep 13, 2010 at 8:02 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Since version 4.4.x, gcc supports additional format attributes.
>    __attribute__ ((format (gnu_printf, 1, 2)))
> should be used instead of
>    __attribute__ ((format (printf, 1, 2))
> because QEMU always uses standard format strings (even with mingw32).
>
> The patch replaces format attribute printf / __printf__ by gnu_printf.
>
> It also removes an #ifdef __GNUC__ (not needed as long as we compile
> with gcc, and for non-gcc compilers we need more changes than this).
>
> The gcc documentation uses format (not __format__), the majority in
> QEMU uses this shorter form, too. Therefore the patch also replaces
> __format__ by format.
>
> Spacing was unified (again as in the gcc documentation).

Please avoid GNU style spacing. This is C, not LISP.

> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  audio/audio.h      |    5 +----
>  audio/audio_int.h  |    4 ++--
>  bsd-user/qemu.h    |    2 +-
>  cpu-all.h          |    2 +-
>  darwin-user/qemu.h |    2 +-
>  hw/xen_backend.h   |    2 +-
>  linux-user/qemu.h  |    2 +-
>  monitor.h          |    2 +-
>  qemu-common.h      |    2 +-
>  qemu-error.h       |    8 +++++---
>  qerror.h           |    2 +-
>  qjson.h            |    2 +-
>  12 files changed, 17 insertions(+), 18 deletions(-)
>
> diff --git a/audio/audio.h b/audio/audio.h
> index 454ade2..4439b82 100644
> --- a/audio/audio.h
> +++ b/audio/audio.h
> @@ -88,10 +88,7 @@ typedef struct QEMUAudioTimeStamp {
>
>  void AUD_vlog (const char *cap, const char *fmt, va_list ap);
>  void AUD_log (const char *cap, const char *fmt, ...)
> -#ifdef __GNUC__
> -    __attribute__ ((__format__ (__printf__, 2, 3)))
> -#endif
> -    ;
> +    __attribute__ ((format (gnu_printf, 2, 3)));
>
>  void AUD_help (void);
>  void AUD_register_card (const char *name, QEMUSoundCard *card);
> diff --git a/audio/audio_int.h b/audio/audio_int.h
> index 06e313f..f6a77ad 100644
> --- a/audio/audio_int.h
> +++ b/audio/audio_int.h
> @@ -237,8 +237,8 @@ static inline int audio_ring_dist (int dst, int src, int len)
>  }
>
>  #if defined __GNUC__
> -#define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2)))
> -#define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (__printf__, n, m)))
> +#define GCC_ATTR __attribute__ ((__unused__, format (gnu_printf, 1, 2)))
> +#define GCC_FMT_ATTR(n, m) __attribute__ ((format (gnu_printf, n, m)))

I'd rather move this macro to a central header and converting instead
users of other syntax. The macro could be defined differently
depending on whether gnu_printf is supported or not. Then we would not
need any -Dgnu_printf=printf in 1/2, which can cause problems.

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

* Re: [Qemu-devel] [PATCH] mips_fulong2e: Detect format errors for function prom_set
  2010-09-11  6:46 [Qemu-devel] [PATCH] mips_fulong2e: Detect format errors for function prom_set Stefan Weil
  2010-09-11  6:46 ` [Qemu-devel] [PATCH] mips_malta: " Stefan Weil
@ 2010-09-20 19:03 ` Blue Swirl
  2010-09-20 20:18   ` [Qemu-devel] [PATCH 1/2] mips_fulong2e: Fix format strings Stefan Weil
  2010-09-20 20:18   ` [Qemu-devel] [PATCH 2/2] mips_malta: " Stefan Weil
  1 sibling, 2 replies; 19+ messages in thread
From: Blue Swirl @ 2010-09-20 19:03 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers, Aurelien Jarno

On Sat, Sep 11, 2010 at 6:46 AM, Stefan Weil <weil@mail.berlios.de> wrote:
> Add the necessary gcc attribute and fix the detected errors.

The fixes are correct, so those parts could be applied.

However the gnu_printf part will break with older compilers unless 1/2
is applied first. That part should also use GCC_FMT_ATTR macro. Please
split the patch.

>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  hw/mips_fulong2e.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
> index cbe7156..2ef5070 100644
> --- a/hw/mips_fulong2e.c
> +++ b/hw/mips_fulong2e.c
> @@ -77,6 +77,8 @@ static struct _loaderparams {
>  } loaderparams;
>
>  static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
> +    __attribute__ ((format (gnu_printf, 3, 4)));
> +static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
>  {
>     va_list ap;
>     int32_t table_addr;
> @@ -141,13 +143,13 @@ static int64_t load_kernel (CPUState *env)
>     prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
>     prom_buf = qemu_malloc(prom_size);
>
> -    prom_set(prom_buf, index++, loaderparams.kernel_filename);
> +    prom_set(prom_buf, index++, "%s", loaderparams.kernel_filename);
>     if (initrd_size > 0) {
> -        prom_set(prom_buf, index++, "rd_start=0x" PRIx64 " rd_size=%li %s",
> +        prom_set(prom_buf, index++, "rd_start=0x%" PRIx64 " rd_size=%li %s",
>                  cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size,
>                  loaderparams.kernel_cmdline);
>     } else {
> -        prom_set(prom_buf, index++, loaderparams.kernel_cmdline);
> +        prom_set(prom_buf, index++, "%s", loaderparams.kernel_cmdline);
>     }
>
>     /* Setup minimum environment variables */
> --
> 1.7.0.4
>
>
>

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

* Re: [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set
  2010-09-11  6:46 ` [Qemu-devel] [PATCH] mips_malta: " Stefan Weil
  2010-09-13 20:02   ` [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf Stefan Weil
  2010-09-13 20:02   ` [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf Stefan Weil
@ 2010-09-20 19:04   ` Blue Swirl
  2 siblings, 0 replies; 19+ messages in thread
From: Blue Swirl @ 2010-09-20 19:04 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers, Aurelien Jarno

On Sat, Sep 11, 2010 at 6:46 AM, Stefan Weil <weil@mail.berlios.de> wrote:
> Add the necessary gcc attribute and fix the detected errors.

This is identical to fulong patch, so my comments on that one apply also here.

>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  hw/mips_malta.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/mips_malta.c b/hw/mips_malta.c
> index a458c97..deee273 100644
> --- a/hw/mips_malta.c
> +++ b/hw/mips_malta.c
> @@ -684,6 +684,8 @@ static void write_bootloader (CPUState *env, uint8_t *base,
>  }
>
>  static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
> +    __attribute__ ((format (gnu_printf, 3, 4)));
> +static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
>  {
>     va_list ap;
>     int32_t table_addr;
> @@ -750,13 +752,13 @@ static int64_t load_kernel(int big_endian)
>     prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
>     prom_buf = qemu_malloc(prom_size);
>
> -    prom_set(prom_buf, prom_index++, loaderparams.kernel_filename);
> +    prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
>     if (initrd_size > 0) {
>         prom_set(prom_buf, prom_index++, "rd_start=0x%" PRIx64 " rd_size=%li %s",
>                  cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size,
>                  loaderparams.kernel_cmdline);
>     } else {
> -        prom_set(prom_buf, prom_index++, loaderparams.kernel_cmdline);
> +        prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline);
>     }
>
>     prom_set(prom_buf, prom_index++, "memsize");
> --
> 1.7.0.4
>
>
>

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

* Re: [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf
  2010-09-13 20:02   ` [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf Stefan Weil
@ 2010-09-20 19:18     ` Blue Swirl
  2010-09-20 21:03       ` Stefan Weil
  2010-09-20 21:05       ` [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file Stefan Weil
  0 siblings, 2 replies; 19+ messages in thread
From: Blue Swirl @ 2010-09-20 19:18 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

On Mon, Sep 13, 2010 at 8:02 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Since version 4.4.x, gcc supports additional format attributes.
>    __attribute__ ((format (gnu_printf, 1, 2)))
> should be used instead of
>    __attribute__ ((format (printf, 1, 2))
> because QEMU always uses standard format strings (even with mingw32).
>
> For older compilers, we simply define gnu_printf = printf,
> so they work with the new format attribute, too.
>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  configure |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/configure b/configure
> index 4061cb7..1300879 100755
> --- a/configure
> +++ b/configure
> @@ -148,6 +148,17 @@ for flag in $gcc_flags; do
>     fi
>  done
>
> +# Check gnu_printf (supported by gcc >= 4.4.x).
> +cat > $TMPC << EOF
> +static void test(const char *format, ...)
> +    __attribute__ ((format (gnu_printf, 1, 2)));
> +static void test(const char *format, ...) {}
> +int main(void) { test("\n"); return 0; }
> +EOF
> +if ! compile_prog "-Werror" ""; then
> +    QEMU_CFLAGS="-Dgnu_printf=printf $QEMU_CFLAGS"

This could cause problems, for example if system headers declared a
function called gnu_printf.

I'd introduce CONFIG_GCC_FMT_ATTR_GNU_PRINTF and adjust GCC_FMT_ATTR
definition based on that.

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

* [Qemu-devel] [PATCH 1/2] mips_fulong2e: Fix format strings
  2010-09-20 19:03 ` [Qemu-devel] [PATCH] mips_fulong2e: " Blue Swirl
@ 2010-09-20 20:18   ` Stefan Weil
  2010-09-21 19:48     ` [Qemu-devel] " Blue Swirl
  2010-09-20 20:18   ` [Qemu-devel] [PATCH 2/2] mips_malta: " Stefan Weil
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Weil @ 2010-09-20 20:18 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl, Aurelien Jarno

Fix two compiler warnings (when format attribute is applied)
and one error (missing %) in format strings.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/mips_fulong2e.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index ac82067..61ca9c4 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -141,13 +141,13 @@ static int64_t load_kernel (CPUState *env)
     prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
     prom_buf = qemu_malloc(prom_size);
 
-    prom_set(prom_buf, index++, loaderparams.kernel_filename);
+    prom_set(prom_buf, index++, "%s", loaderparams.kernel_filename);
     if (initrd_size > 0) {
-        prom_set(prom_buf, index++, "rd_start=0x" PRIx64 " rd_size=%li %s",
+        prom_set(prom_buf, index++, "rd_start=0x%" PRIx64 " rd_size=%li %s",
                  cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size,
                  loaderparams.kernel_cmdline);
     } else {
-        prom_set(prom_buf, index++, loaderparams.kernel_cmdline);
+        prom_set(prom_buf, index++, "%s", loaderparams.kernel_cmdline);
     }
 
     /* Setup minimum environment variables */
-- 
1.7.1

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

* [Qemu-devel] [PATCH 2/2] mips_malta: Fix format strings
  2010-09-20 19:03 ` [Qemu-devel] [PATCH] mips_fulong2e: " Blue Swirl
  2010-09-20 20:18   ` [Qemu-devel] [PATCH 1/2] mips_fulong2e: Fix format strings Stefan Weil
@ 2010-09-20 20:18   ` Stefan Weil
  2010-09-21 19:48     ` [Qemu-devel] " Blue Swirl
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Weil @ 2010-09-20 20:18 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl, Aurelien Jarno

Fix two compiler warnings (when format attribute is applied).

Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/mips_malta.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index ec95cd8..1cb7880 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -728,13 +728,13 @@ static int64_t load_kernel (void)
     prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
     prom_buf = qemu_malloc(prom_size);
 
-    prom_set(prom_buf, prom_index++, loaderparams.kernel_filename);
+    prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
     if (initrd_size > 0) {
         prom_set(prom_buf, prom_index++, "rd_start=0x%" PRIx64 " rd_size=%li %s",
                  cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size,
                  loaderparams.kernel_cmdline);
     } else {
-        prom_set(prom_buf, prom_index++, loaderparams.kernel_cmdline);
+        prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline);
     }
 
     prom_set(prom_buf, prom_index++, "memsize");
-- 
1.7.1

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

* Re: [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf
  2010-09-20 19:18     ` Blue Swirl
@ 2010-09-20 21:03       ` Stefan Weil
  2010-09-20 21:05       ` [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file Stefan Weil
  1 sibling, 0 replies; 19+ messages in thread
From: Stefan Weil @ 2010-09-20 21:03 UTC (permalink / raw)
  To: Blue Swirl; +Cc: QEMU Developers

Am 20.09.2010 21:18, schrieb Blue Swirl:
> On Mon, Sep 13, 2010 at 8:02 PM, Stefan Weil<weil@mail.berlios.de>  wrote:
>    
>> Since version 4.4.x, gcc supports additional format attributes.
>>     __attribute__ ((format (gnu_printf, 1, 2)))
>> should be used instead of
>>     __attribute__ ((format (printf, 1, 2))
>> because QEMU always uses standard format strings (even with mingw32).
>>
>> For older compilers, we simply define gnu_printf = printf,
>> so they work with the new format attribute, too.
>>
>> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
>> ---
>>   configure |   11 +++++++++++
>>   1 files changed, 11 insertions(+), 0 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 4061cb7..1300879 100755
>> --- a/configure
>> +++ b/configure
>> @@ -148,6 +148,17 @@ for flag in $gcc_flags; do
>>      fi
>>   done
>>
>> +# Check gnu_printf (supported by gcc>= 4.4.x).
>> +cat>  $TMPC<<  EOF
>> +static void test(const char *format, ...)
>> +    __attribute__ ((format (gnu_printf, 1, 2)));
>> +static void test(const char *format, ...) {}
>> +int main(void) { test("\n"); return 0; }
>> +EOF
>> +if ! compile_prog "-Werror" ""; then
>> +    QEMU_CFLAGS="-Dgnu_printf=printf $QEMU_CFLAGS"
>>      
> This could cause problems, for example if system headers declared a
> function called gnu_printf.
>
> I'd introduce CONFIG_GCC_FMT_ATTR_GNU_PRINTF and adjust GCC_FMT_ATTR
> definition based on that.
>
>    

Thanks for your review. I'll send a new patch which goes
into the direction which you suggested.

Instead of defining a new macro CONFIG_GCC_FMT_ATTR_GNU_PRINTF,
my new patch checks the gcc version (gnu_printf was introduced
with gcc 4.4). Like this, no changes to file configure are needed.

Regards
Stefan

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

* [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file
  2010-09-20 19:18     ` Blue Swirl
  2010-09-20 21:03       ` Stefan Weil
@ 2010-09-20 21:05       ` Stefan Weil
  2010-09-21 17:46         ` [Qemu-devel] " Stefan Weil
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Weil @ 2010-09-20 21:05 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

By moving the definition of GCC_ATTR and GCC_FMT_ATTR
from audio_int.h to qemu-common.h these macros are
now generally available for further patches which add
the gcc format attribute.

Newer gcc versions support format gnu_printf which is
better suited for use in QEMU than format printf
(QEMU always uses standard format strings (even with mingw32)).

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 audio/audio_int.h |    8 --------
 qemu-common.h     |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/audio/audio_int.h b/audio/audio_int.h
index f6a77ad..d8560b6 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -236,14 +236,6 @@ static inline int audio_ring_dist (int dst, int src, int len)
     return (dst >= src) ? (dst - src) : (len - src + dst);
 }
 
-#if defined __GNUC__
-#define GCC_ATTR __attribute__ ((__unused__, format (gnu_printf, 1, 2)))
-#define GCC_FMT_ATTR(n, m) __attribute__ ((format (gnu_printf, n, m)))
-#else
-#define GCC_ATTR /**/
-#define GCC_FMT_ATTR(n, m)
-#endif
-
 static void GCC_ATTR dolog (const char *fmt, ...)
 {
     va_list ap;
diff --git a/qemu-common.h b/qemu-common.h
index 956b545..8a2872a 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -70,6 +70,22 @@ struct iovec {
 #include <sys/uio.h>
 #endif
 
+#if defined __GNUC__
+# if (__GNUC__ < 4) || \
+     defined(__GNUC_MINOR__) && (__GNUC__ = 4) && (__GNUC_MINOR__ < 4)
+   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
+#  define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2)))
+#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
+# else
+   /* Use gnu_printf when supported (qemu uses standard format strings). */
+#  define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
+#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
+# endif
+#else
+#define GCC_ATTR /**/
+#define GCC_FMT_ATTR(n, m)
+#endif
+
 #ifdef _WIN32
 #define fsync _commit
 #define lseek _lseeki64
-- 
1.7.1

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

* [Qemu-devel] Re: [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file
  2010-09-20 21:05       ` [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file Stefan Weil
@ 2010-09-21 17:46         ` Stefan Weil
  2010-09-21 17:48           ` [Qemu-devel] " Stefan Weil
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Weil @ 2010-09-21 17:46 UTC (permalink / raw)
  To: Blue Swirl; +Cc: QEMU Developers

Please ignore this patch. It's wrong (= instead of ==).
I'll send a fixed version.

Sorry,
Stefan

Am 20.09.2010 23:05, schrieb Stefan Weil:
> By moving the definition of GCC_ATTR and GCC_FMT_ATTR
> from audio_int.h to qemu-common.h these macros are
> now generally available for further patches which add
> the gcc format attribute.
>
> Newer gcc versions support format gnu_printf which is
> better suited for use in QEMU than format printf
> (QEMU always uses standard format strings (even with mingw32)).
>
> Cc: Blue Swirl<blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
> ---
>   audio/audio_int.h |    8 --------
>   qemu-common.h     |   16 ++++++++++++++++
>   2 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/audio/audio_int.h b/audio/audio_int.h
> index f6a77ad..d8560b6 100644
> --- a/audio/audio_int.h
> +++ b/audio/audio_int.h
> @@ -236,14 +236,6 @@ static inline int audio_ring_dist (int dst, int src, int len)
>       return (dst>= src) ? (dst - src) : (len - src + dst);
>   }
>
> -#if defined __GNUC__
> -#define GCC_ATTR __attribute__ ((__unused__, format (gnu_printf, 1, 2)))
> -#define GCC_FMT_ATTR(n, m) __attribute__ ((format (gnu_printf, n, m)))
> -#else
> -#define GCC_ATTR /**/
> -#define GCC_FMT_ATTR(n, m)
> -#endif
> -
>   static void GCC_ATTR dolog (const char *fmt, ...)
>   {
>       va_list ap;
> diff --git a/qemu-common.h b/qemu-common.h
> index 956b545..8a2872a 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -70,6 +70,22 @@ struct iovec {
>   #include<sys/uio.h>
>   #endif
>
> +#if defined __GNUC__
> +# if (__GNUC__<  4) || \
> +     defined(__GNUC_MINOR__)&&  (__GNUC__ = 4)&&  (__GNUC_MINOR__<  4)
> +   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
> +#  define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2)))
> +#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
> +# else
> +   /* Use gnu_printf when supported (qemu uses standard format strings). */
> +#  define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
> +#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
> +# endif
> +#else
> +#define GCC_ATTR /**/
> +#define GCC_FMT_ATTR(n, m)
> +#endif
> +
>   #ifdef _WIN32
>   #define fsync _commit
>   #define lseek _lseeki64
>    

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

* [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file
  2010-09-21 17:46         ` [Qemu-devel] " Stefan Weil
@ 2010-09-21 17:48           ` Stefan Weil
  2010-09-21 18:17             ` [Qemu-devel] " Blue Swirl
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Weil @ 2010-09-21 17:48 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

By moving the definition of GCC_ATTR and GCC_FMT_ATTR
from audio_int.h to qemu-common.h these macros are
now generally available for further patches which add
the gcc format attribute.

Newer gcc versions support format gnu_printf which is
better suited for use in QEMU than format printf
(QEMU always uses standard format strings (even with mingw32)).

V2: Use correct operator '==' (instead of '=')

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 audio/audio_int.h |    8 --------
 qemu-common.h     |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/audio/audio_int.h b/audio/audio_int.h
index f6a77ad..d8560b6 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -236,14 +236,6 @@ static inline int audio_ring_dist (int dst, int src, int len)
     return (dst >= src) ? (dst - src) : (len - src + dst);
 }
 
-#if defined __GNUC__
-#define GCC_ATTR __attribute__ ((__unused__, format (gnu_printf, 1, 2)))
-#define GCC_FMT_ATTR(n, m) __attribute__ ((format (gnu_printf, n, m)))
-#else
-#define GCC_ATTR /**/
-#define GCC_FMT_ATTR(n, m)
-#endif
-
 static void GCC_ATTR dolog (const char *fmt, ...)
 {
     va_list ap;
diff --git a/qemu-common.h b/qemu-common.h
index 956b545..e97a96e 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -70,6 +70,22 @@ struct iovec {
 #include <sys/uio.h>
 #endif
 
+#if defined __GNUC__
+# if (__GNUC__ < 4) || \
+     defined(__GNUC_MINOR__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4)
+   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
+#  define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2)))
+#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
+# else
+   /* Use gnu_printf when supported (qemu uses standard format strings). */
+#  define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
+#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
+# endif
+#else
+#define GCC_ATTR /**/
+#define GCC_FMT_ATTR(n, m)
+#endif
+
 #ifdef _WIN32
 #define fsync _commit
 #define lseek _lseeki64
-- 
1.7.1

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

* [Qemu-devel] Re: [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file
  2010-09-21 17:48           ` [Qemu-devel] " Stefan Weil
@ 2010-09-21 18:17             ` Blue Swirl
  2010-09-21 20:27               ` [Qemu-devel] " Stefan Weil
  0 siblings, 1 reply; 19+ messages in thread
From: Blue Swirl @ 2010-09-21 18:17 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

On Tue, Sep 21, 2010 at 5:48 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> By moving the definition of GCC_ATTR and GCC_FMT_ATTR
> from audio_int.h to qemu-common.h these macros are
> now generally available for further patches which add
> the gcc format attribute.
>
> Newer gcc versions support format gnu_printf which is
> better suited for use in QEMU than format printf
> (QEMU always uses standard format strings (even with mingw32)).
>
> V2: Use correct operator '==' (instead of '=')
>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  audio/audio_int.h |    8 --------
>  qemu-common.h     |   16 ++++++++++++++++
>  2 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/audio/audio_int.h b/audio/audio_int.h
> index f6a77ad..d8560b6 100644
> --- a/audio/audio_int.h
> +++ b/audio/audio_int.h
> @@ -236,14 +236,6 @@ static inline int audio_ring_dist (int dst, int src, int len)
>     return (dst >= src) ? (dst - src) : (len - src + dst);
>  }
>
> -#if defined __GNUC__
> -#define GCC_ATTR __attribute__ ((__unused__, format (gnu_printf, 1, 2)))
> -#define GCC_FMT_ATTR(n, m) __attribute__ ((format (gnu_printf, n, m)))

The patch doesn't apply, the above lines do not match HEAD.

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

* [Qemu-devel] Re: [PATCH 1/2] mips_fulong2e: Fix format strings
  2010-09-20 20:18   ` [Qemu-devel] [PATCH 1/2] mips_fulong2e: Fix format strings Stefan Weil
@ 2010-09-21 19:48     ` Blue Swirl
  0 siblings, 0 replies; 19+ messages in thread
From: Blue Swirl @ 2010-09-21 19:48 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers, Aurelien Jarno

Thanks, applied.

On Mon, Sep 20, 2010 at 8:18 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Fix two compiler warnings (when format attribute is applied)
> and one error (missing %) in format strings.
>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  hw/mips_fulong2e.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
> index ac82067..61ca9c4 100644
> --- a/hw/mips_fulong2e.c
> +++ b/hw/mips_fulong2e.c
> @@ -141,13 +141,13 @@ static int64_t load_kernel (CPUState *env)
>     prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
>     prom_buf = qemu_malloc(prom_size);
>
> -    prom_set(prom_buf, index++, loaderparams.kernel_filename);
> +    prom_set(prom_buf, index++, "%s", loaderparams.kernel_filename);
>     if (initrd_size > 0) {
> -        prom_set(prom_buf, index++, "rd_start=0x" PRIx64 " rd_size=%li %s",
> +        prom_set(prom_buf, index++, "rd_start=0x%" PRIx64 " rd_size=%li %s",
>                  cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size,
>                  loaderparams.kernel_cmdline);
>     } else {
> -        prom_set(prom_buf, index++, loaderparams.kernel_cmdline);
> +        prom_set(prom_buf, index++, "%s", loaderparams.kernel_cmdline);
>     }
>
>     /* Setup minimum environment variables */
> --
> 1.7.1
>
>

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

* [Qemu-devel] Re: [PATCH 2/2] mips_malta: Fix format strings
  2010-09-20 20:18   ` [Qemu-devel] [PATCH 2/2] mips_malta: " Stefan Weil
@ 2010-09-21 19:48     ` Blue Swirl
  0 siblings, 0 replies; 19+ messages in thread
From: Blue Swirl @ 2010-09-21 19:48 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers, Aurelien Jarno

Thanks, applied.

On Mon, Sep 20, 2010 at 8:18 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Fix two compiler warnings (when format attribute is applied).
>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  hw/mips_malta.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/mips_malta.c b/hw/mips_malta.c
> index ec95cd8..1cb7880 100644
> --- a/hw/mips_malta.c
> +++ b/hw/mips_malta.c
> @@ -728,13 +728,13 @@ static int64_t load_kernel (void)
>     prom_size = ENVP_NB_ENTRIES * (sizeof(int32_t) + ENVP_ENTRY_SIZE);
>     prom_buf = qemu_malloc(prom_size);
>
> -    prom_set(prom_buf, prom_index++, loaderparams.kernel_filename);
> +    prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename);
>     if (initrd_size > 0) {
>         prom_set(prom_buf, prom_index++, "rd_start=0x%" PRIx64 " rd_size=%li %s",
>                  cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size,
>                  loaderparams.kernel_cmdline);
>     } else {
> -        prom_set(prom_buf, prom_index++, loaderparams.kernel_cmdline);
> +        prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline);
>     }
>
>     prom_set(prom_buf, prom_index++, "memsize");
> --
> 1.7.1
>
>

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

* [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file
  2010-09-21 18:17             ` [Qemu-devel] " Blue Swirl
@ 2010-09-21 20:27               ` Stefan Weil
  2010-09-22 20:30                 ` [Qemu-devel] " Blue Swirl
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Weil @ 2010-09-21 20:27 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

By moving the definition of GCC_ATTR and GCC_FMT_ATTR
from audio_int.h to qemu-common.h these macros are
now generally available for further patches which add
the gcc format attribute.

Newer gcc versions support format gnu_printf which is
better suited for use in QEMU than format printf
(QEMU always uses standard format strings (even with mingw32)).

V2: Use correct operator '==' (instead of '=')

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 audio/audio_int.h |    8 --------
 qemu-common.h     |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/audio/audio_int.h b/audio/audio_int.h
index 06e313f..d8560b6 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -236,14 +236,6 @@ static inline int audio_ring_dist (int dst, int src, int len)
     return (dst >= src) ? (dst - src) : (len - src + dst);
 }
 
-#if defined __GNUC__
-#define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2)))
-#define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (__printf__, n, m)))
-#else
-#define GCC_ATTR /**/
-#define GCC_FMT_ATTR(n, m)
-#endif
-
 static void GCC_ATTR dolog (const char *fmt, ...)
 {
     va_list ap;
diff --git a/qemu-common.h b/qemu-common.h
index dfd3dc0..96be1d4 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -70,6 +70,22 @@ struct iovec {
 #include <sys/uio.h>
 #endif
 
+#if defined __GNUC__
+# if (__GNUC__ < 4) || \
+     defined(__GNUC_MINOR__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4)
+   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
+#  define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2)))
+#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
+# else
+   /* Use gnu_printf when supported (qemu uses standard format strings). */
+#  define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
+#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
+# endif
+#else
+#define GCC_ATTR /**/
+#define GCC_FMT_ATTR(n, m)
+#endif
+
 #ifdef _WIN32
 #define fsync _commit
 #define lseek _lseeki64
-- 
1.7.1

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

* [Qemu-devel] Re: [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file
  2010-09-21 20:27               ` [Qemu-devel] " Stefan Weil
@ 2010-09-22 20:30                 ` Blue Swirl
  0 siblings, 0 replies; 19+ messages in thread
From: Blue Swirl @ 2010-09-22 20:30 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

Thanks, applied.

On Tue, Sep 21, 2010 at 8:27 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> By moving the definition of GCC_ATTR and GCC_FMT_ATTR
> from audio_int.h to qemu-common.h these macros are
> now generally available for further patches which add
> the gcc format attribute.
>
> Newer gcc versions support format gnu_printf which is
> better suited for use in QEMU than format printf
> (QEMU always uses standard format strings (even with mingw32)).
>
> V2: Use correct operator '==' (instead of '=')
>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  audio/audio_int.h |    8 --------
>  qemu-common.h     |   16 ++++++++++++++++
>  2 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/audio/audio_int.h b/audio/audio_int.h
> index 06e313f..d8560b6 100644
> --- a/audio/audio_int.h
> +++ b/audio/audio_int.h
> @@ -236,14 +236,6 @@ static inline int audio_ring_dist (int dst, int src, int len)
>     return (dst >= src) ? (dst - src) : (len - src + dst);
>  }
>
> -#if defined __GNUC__
> -#define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2)))
> -#define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (__printf__, n, m)))
> -#else
> -#define GCC_ATTR /**/
> -#define GCC_FMT_ATTR(n, m)
> -#endif
> -
>  static void GCC_ATTR dolog (const char *fmt, ...)
>  {
>     va_list ap;
> diff --git a/qemu-common.h b/qemu-common.h
> index dfd3dc0..96be1d4 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -70,6 +70,22 @@ struct iovec {
>  #include <sys/uio.h>
>  #endif
>
> +#if defined __GNUC__
> +# if (__GNUC__ < 4) || \
> +     defined(__GNUC_MINOR__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4)
> +   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
> +#  define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2)))
> +#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
> +# else
> +   /* Use gnu_printf when supported (qemu uses standard format strings). */
> +#  define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
> +#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
> +# endif
> +#else
> +#define GCC_ATTR /**/
> +#define GCC_FMT_ATTR(n, m)
> +#endif
> +
>  #ifdef _WIN32
>  #define fsync _commit
>  #define lseek _lseeki64
> --
> 1.7.1
>
>

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

end of thread, other threads:[~2010-09-22 20:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-11  6:46 [Qemu-devel] [PATCH] mips_fulong2e: Detect format errors for function prom_set Stefan Weil
2010-09-11  6:46 ` [Qemu-devel] [PATCH] mips_malta: " Stefan Weil
2010-09-13 20:02   ` [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf Stefan Weil
2010-09-20 19:18     ` Blue Swirl
2010-09-20 21:03       ` Stefan Weil
2010-09-20 21:05       ` [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file Stefan Weil
2010-09-21 17:46         ` [Qemu-devel] " Stefan Weil
2010-09-21 17:48           ` [Qemu-devel] " Stefan Weil
2010-09-21 18:17             ` [Qemu-devel] " Blue Swirl
2010-09-21 20:27               ` [Qemu-devel] " Stefan Weil
2010-09-22 20:30                 ` [Qemu-devel] " Blue Swirl
2010-09-13 20:02   ` [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf Stefan Weil
2010-09-20 18:53     ` Blue Swirl
2010-09-20 19:04   ` [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set Blue Swirl
2010-09-20 19:03 ` [Qemu-devel] [PATCH] mips_fulong2e: " Blue Swirl
2010-09-20 20:18   ` [Qemu-devel] [PATCH 1/2] mips_fulong2e: Fix format strings Stefan Weil
2010-09-21 19:48     ` [Qemu-devel] " Blue Swirl
2010-09-20 20:18   ` [Qemu-devel] [PATCH 2/2] mips_malta: " Stefan Weil
2010-09-21 19:48     ` [Qemu-devel] " Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).