audio: Replace macro GCC_ATTR by GCC_FMT_ATTR and use inline functions
PATCH 1/1 audio: Replace macro GCC_ATTR by GCC_FMT_ATTR and use inline functions
GCC_ATTR was only used in audio_int.h, so it is now unused and the definition can be removed from compiler.h.
--- audio/audio_int.h | 8 +++----- include/qemu/compiler.h | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-)
audio/audio_int.h +3 -5
@@ -243,7 +243,7 @@ static inline int audio_ring_dist (int dst, int src, int len)return (dst >= src) ? (dst - src) : (len - src + dst); } -static void GCC_ATTR dolog (const char *fmt, ...) +static inline void GCC_FMT_ATTR(1, 2) dolog (const char *fmt, ...) {va_list ap;
@@ -253,7 +253,7 @@ static void GCC_ATTR dolog (const char *fmt, ...) } #ifdef DEBUG -static void GCC_ATTR ldebug (const char *fmt, ...) +static inline void GCC_FMT_ATTR(1, 2) ldebug (const char *fmt, ...) { va_list ap;
@@ -267,15 +267,13 @@ static void GCC_ATTR ldebug (const char *fmt, ...) #elif defined NDEBUG && defined _MSC_VER #define ldebug __noop #else -static void GCC_ATTR ldebug (const char *fmt, ...) +static inline void GCC_FMT_ATTR(1, 2) ldebug (const char *fmt, ...) { (void) fmt; } #endif #endif -#undef GCC_ATTR - #define AUDIO_STRINGIFY_(n) #n #define AUDIO_STRINGIFY(n) AUDIO_STRINGIFY_(n)
include/qemu/compiler.h +0 -3
@@ -38,11 +38,9 @@#if defined __GNUC__# if !QEMU_GNUC_PREREQ (4 ,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)))# if defined(_WIN32)/* Map __printf__ to __gnu_printf__ because we want standard format strings
@@ -51,7 +49,6 @@# endif # endif #else -#define GCC_ATTR /**/ #define GCC_FMT_ATTR (n, m)#endif
Signature · 1 line
1.7.10.4
Am 09.06.2013 14:22, schrieb Stefan Weil:
Quoted 4 lines
GCC_ATTRwas only used inaudio_int.h, so it is now unused and the definition can be removed fromcompiler.h.Signed-off-by Stefan Weil <[email protected]>
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Michael Tokarev
AppliedQuoted 2 lines · Stefan Weil
GCC_ATTRwas only used inaudio_int.h, so it is now unused and the definition can be removed fromcompiler.h.
Thanks, applied to the trivial patches queue.
/mjt
[Removing malc's email since it bounces]
Quoted 14 lines · Stefan Weil
GCC_ATTRwas only used inaudio_int.h, so it is now unused and the definition can be removed fromcompiler.h.Signed-off-by Stefan Weil <[email protected]>--- audio/audio_int.h | 8 +++----- include/qemu/compiler.h | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-)audio/audio_int.h +0
-0
audio/audio_int.h static inline int audio_ring_dist (int dst, int src, int len) · line 246
Quoted 5 lines
audio/audio_int.h +1
-1@@ -243,7 +243,7 @@ static inline int audio_ring_dist (int dst, int src, int len)return (dst >= src) ? (dst - src) : (len - src + dst); } -static void GCC_ATTR dolog (const char *fmt, ...) +static inline void GCC_FMT_ATTR(1, 2) dolog (const char *fmt, ...)
This change (adding `inline') causes build failure with at least with gcc-4.7:
audio/wavaudio.c: In function ‘dolog’:audio/audio_int.h:246:100: error: function ‘dolog’ can never be inlined because it uses variable argument lists
$ gcc --version gcc (Debian 4.7.2-5) 4.7.2
I think the addition of inline should be dropped here and in other similar places (the rest is ok).
I can do that myself if you want.
Alternatively these functions can be turned into varargs #defines.
Thanks,
/mjt
Am 11.06.2013 14:38, schrieb Michael Tokarev:
Quoted 27 lines
[Removing malc's email since it bounces]
Quoted 14 lines · Stefan Weil
GCC_ATTRwas only used inaudio_int.h, so it is now unused and the definition can be removed fromcompiler.h.Signed-off-by Stefan Weil <[email protected]>--- audio/audio_int.h | 8 +++----- include/qemu/compiler.h | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-)audio/audio_int.h +0
-0audio/audio_int.h static inline int audio_ring_dist (int dst, int src, int len) · line 246
Quoted 5 lines
audio/audio_int.h +1
-1@@ -243,7 +243,7 @@ static inline int audio_ring_dist (int dst, int src, int len)return (dst >= src) ? (dst - src) : (len - src + dst); } -static void GCC_ATTR dolog (const char *fmt, ...) +static inline void GCC_FMT_ATTR(1, 2) dolog (const char *fmt, ...)This change (adding `inline') causes build failure with at least with gcc-4.7:
audio/wavaudio.c: In function ‘dolog’:audio/audio_int.h:246:100: error: function ‘dolog’ can never be inlined because it uses variable argument lists
Quoted 7 lines
$ gcc --version gcc (Debian 4.7.2-5) 4.7.2I think the addition of inline should be dropped here and in other similar places (the rest is ok).
I can do that myself if you want.
But having a static function in the header still needs the __unused__ attribute, which this patch tries to remove, doesn't it?
Andreas
Quoted 7 lines
Alternatively these functions can be turned into varargs #defines.
Thanks,
/mjt
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Am 11.06.2013 14:38, schrieb Michael Tokarev:
Quoted 6 lines
[Removing malc's email since it bounces]
Quoted 4 lines · Stefan Weil
GCC_ATTRwas only used inaudio_int.h, so it is now unused and the definition can be removed fromcompiler.h.Signed-off-by Stefan Weil <[email protected]>
[snip]
Quoted 11 lines
This change (adding `inline') causes build failure with at least with gcc-4.7:
audio/wavaudio.c: In function ‘dolog’:audio/audio_int.h:246:100: error: function ‘dolog’ can never be inlined because it uses variable argument lists$ gcc --version gcc (Debian 4.7.2-5) 4.7.2I think the addition of inline should be dropped here and in other similar places (the rest is ok).
Quoted 7 lines
I can do that myself if you want.
Alternatively these functions can be turned into varargs #defines.
Thanks,
/mjt
Thank you for reporting this compiler problem. I did not see it because I configured with -enable-debugwhich disables inline functions.
I'll send a new patch which uses macros.
Regards
Stefan