fix a few clang warnings
cover fix a few clang warnings
All of these should be quite uncontroversial. The vnc.c change is not what you'd expect though (could be a real bug, so I leave the clang warning).
I'll propose the second patch for 0.12 after a short while.
Paolo Bonzini (6):
remove two dead assignments in target-i386/translate.c fix undefined shifts by >32
exec.c: dead assignments
vnc.c: warn about ignored option
usb-linux.c: remove write-only variable
fix audio_bug related failures
audio/audio.c | 44 ++++++++++++++++++++------------------------ audio/audio_int.h | 3 ++- exec.c | 4 ---- target-i386/translate.c | 2 -- usb-linux.c | 2 -- vl.c | 4 ++-- vnc.c | 1 + 7 files changed, 25 insertions(+), 35 deletions(-)
PATCH 1/6 remove two dead assignments in target-i386/translate.c
--- target-i386/translate.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
target-i386/translate.c +0 -2
@@ -4692,8 +4692,6 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start) ot = dflag +OT_WORD ; modrm =ldub_code (s->pc++); - mod = (modrm >>6 ) &3 ; - rm = (modrm &7 ) |REX_B (s); reg = ((modrm >>3 ) &7 ) | rex_r;gen_ldst_modrm (s, modrm, ot,OR_TMP0 ,0 );
Signature · 1 line
1.6.6
PATCH 2/6 fix undefined shifts by >32
In reply to Paolo Bonzini--- vl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
vl.c +2 -2
@@ -2373,9 +2373,9 @@ static void numa_add(const char *optarg)fprintf (stderr,"only 63 CPUs in NUMA mode supported.\n" ); } - value = (1 << (endvalue +1 )) - (1 << value); + value = (2ULL << endvalue) - (1ULL << value); }else { - value =1 << value; + value =1ULL << value; } } node_cpumask[nodenr] = value;
Signature · 1 line
1.6.6
PATCH 3/6 exec.c: dead assignments
In reply to Paolo Bonzini--- exec.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
exec.c +0 -4
@@ -2489,17 +2489,13 @@ void *qemu_get_ram_ptr(ram_addr_t addr)ram_addr_t qemu_ram_addr_from_host (void *ptr) {RAMBlock *prev; -RAMBlock **prevp;RAMBlock *block;uint8_t *host = ptr; prev =NULL ; - prevp = &ram_blocks; block = ram_blocks;while (block && (block->host > host || block->host + block->length <= host)) { -if (prev) - prevp = &prev->next; prev = block; block = block->next; }
Signature · 1 line
1.6.6
PATCH 4/6 vnc.c: warn about ignored option
In reply to Paolo Bonzini--- vnc.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
vnc.c +1 -0
@@ -2563,6 +2563,7 @@ int vnc_display_open(DisplayState *ds, const char *display) reverse =1 ; }else if (strncmp (options,"to=" ,3 ) ==0 ) { to_port =atoi (options+3 ) +5900 ; +fprintf (stderr,"qemu: warning: to= option for -vnc ignored\n" ); #ifdef CONFIG_VNC_SASL }else if (strncmp (options,"sasl" ,4 ) ==0 ) { sasl =1 ;/* Require SASL auth */
Signature · 1 line
1.6.6
Re: [Qemu-devel] [PATCH 4/6] vnc.c: warn about ignored option
Quoted 10 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini<[email protected]>--- vnc.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)vnc.c +0
-0
vnc.c int vnc_display_open(DisplayState *ds, const char *display) · line 2567
Quoted 5 lines
vnc.c +1
-0@@ -2563,6 +2563,7 @@ int vnc_display_open(DisplayState *ds, const char *display) reverse =1 ; }else if (strncmp (options,"to=" ,3 ) ==0 ) { to_port =atoi (options+3 ) +5900 ; +fprintf (stderr,"qemu: warning: to= option for -vnc ignored\n" );
If we're ignoring it, why even have the code? How did clang spot this?
Regards,
Anthony Liguori
Re: [Qemu-devel] [PATCH 4/6] vnc.c: warn about ignored option
Quoted 6 lines · Anthony Liguori
Quoted 5 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini<[email protected]>---
vnc.c| 1 +1 files changed, 1 insertions(+), 0 deletions(-)
Quoted 12 lines
vnc.c int vnc_display_open(DisplayState *ds, const · line 2567
Quoted 10 lines
vnc.c +1
-0@@ -2563,6 +2563,7 @@ int vnc_display_open(DisplayState *ds, const char *display) reverse =1 ; }else if (strncmp (options,"to=" ,3 ) ==0 ) { to_port =atoi (options+3 ) +5900 ; +fprintf (stderr,"qemu: warning: to= option for -vnc ignored\n" );If we're ignoring it, why even have the code? How did clang spot this?
to= isn't ignored. The to= handling has been moved to qemu-socket.c though a while ago. So clang spotted correctly that to_port variable is unused. The whole 'if (...) {}' is a leftover which can go away now.
cheers,
Gerd
PATCH 5/6 usb-linux.c: remove write-only variable
In reply to Paolo Bonzini--- usb-linux.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
usb-linux.c +0 -2
@@ -1007,11 +1007,9 @@ USBDevice *usb_host_device_open(const char *devname) {struct USBAutoFilter filter;USBDevice *dev; -USBHostDevice *s;char *p; dev =usb_create (NULL /* FIXME */ ,"usb-host" ); - s =DO_UPCAST (USBHostDevice, dev, dev);if (strstr (devname,"auto:" )) {if (parse_filter (devname, &filter) <0 )
Signature · 1 line
1.6.6
PATCH 6/6 fix audio_bug related failures
In reply to Paolo Bonzini--- audio/audio.c | 44 ++++++++++++++++++++------------------------ audio/audio_int.h | 3 ++- 2 files changed, 22 insertions(+), 25 deletions(-)
audio/audio.c +20 -24
@@ -118,42 +118,38 @@ struct mixeng_volume nominal_volume = {static void audio_print_options (const char *prefix,struct audio_option *opt); -int audio_bug (const char *funcname,int cond) +void audio_bug_found (const char *funcname) { -if (cond) { -static int shown; - -AUD_log (NULL ,"A bug was just triggered in %s\n" , funcname); -if (!shown) { -struct audio_driver *d; - - shown =1 ; -AUD_log (NULL ,"Save all your work and restart without audio\n" ); -AUD_log (NULL ,"Please send bug report to [email protected]\n" ); -AUD_log (NULL ,"I am sorry\n" ); - d = glob_audio_state.drv; -if (d) { -audio_print_options (d->name, d->options); - } +static int shown; + +AUD_log (NULL ,"A bug was just triggered in %s\n" , funcname); +if (!shown) { +struct audio_driver *d; + + shown =1 ; +AUD_log (NULL ,"Save all your work and restart without audio\n" ); +AUD_log (NULL ,"Please send bug report to [email protected]\n" ); +AUD_log (NULL ,"I am sorry\n" ); + d = glob_audio_state.drv; +if (d) { +audio_print_options (d->name, d->options); } -AUD_log (NULL ,"Context:\n" ); + } +AUD_log (NULL ,"Context:\n" );#if definedAUDIO_BREAKPOINT_ON_BUG # if definedHOST_I386 # if defined __GNUC__ - __asm__ ("int3" ); + __asm__ ("int3" );# elif defined _MSC_VER - _asm _emit 0xcc; + _asm _emit 0xcc;# else -abort (); +abort ();# endif # else -abort (); +abort ();# endif #endif - } - -return cond; }#endif
audio/audio_int.h +2 -1
@@ -223,7 +223,8 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len);int audio_pcm_hw_clip_out (HWVoiceOut *hw,void *pcm_buf,int live,int pending); -int audio_bug (const char *funcname,int cond); +#define audio_bug (funcname, cond) ((cond) ? audio_bug_found (funcname), 1 : 0) +void audio_bug_found (const char *funcname);void *audio_calloc (const char *funcname,int nmemb,size_t size);void audio_run (const char *msg);
Signature · 1 line
1.6.6
Re: [Qemu-devel] [PATCH 6/6] fix audio_bug related failures
What did clang complain about? It's not obvious to me.
Regards,
Anthony Liguori
Quoted 88 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini<[email protected]>--- audio/audio.c | 44 ++++++++++++++++++++------------------------ audio/audio_int.h | 3 ++- 2 files changed, 22 insertions(+), 25 deletions(-)audio/audio.c +20
-24@@ -118,42 +118,38 @@ struct mixeng_volume nominal_volume = {static void audio_print_options (const char *prefix,struct audio_option *opt); -int audio_bug (const char *funcname,int cond) +void audio_bug_found (const char *funcname) { -if (cond) { -static int shown; - -AUD_log (NULL ,"A bug was just triggered in %s\n" , funcname); -if (!shown) { -struct audio_driver *d; - - shown =1 ; -AUD_log (NULL ,"Save all your work and restart without audio\n" ); -AUD_log (NULL ,"Please send bug report to [email protected]\n" ); -AUD_log (NULL ,"I am sorry\n" ); - d = glob_audio_state.drv; -if (d) { -audio_print_options (d->name, d->options); - } +static int shown; + +AUD_log (NULL ,"A bug was just triggered in %s\n" , funcname); +if (!shown) { +struct audio_driver *d; + + shown =1 ; +AUD_log (NULL ,"Save all your work and restart without audio\n" ); +AUD_log (NULL ,"Please send bug report to [email protected]\n" ); +AUD_log (NULL ,"I am sorry\n" ); + d = glob_audio_state.drv; +if (d) { +audio_print_options (d->name, d->options); } -AUD_log (NULL ,"Context:\n" ); + } +AUD_log (NULL ,"Context:\n" );#if definedAUDIO_BREAKPOINT_ON_BUG # if definedHOST_I386 # if defined __GNUC__ - __asm__ ("int3" ); + __asm__ ("int3" );# elif defined _MSC_VER - _asm _emit 0xcc; + _asm _emit 0xcc;# else -abort (); +abort ();# endif # else -abort (); +abort ();# endif #endif - } - -return cond; }#endif audio/audio_int.h +2
-1@@ -223,7 +223,8 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len);int audio_pcm_hw_clip_out (HWVoiceOut *hw,void *pcm_buf,int live,int pending); -int audio_bug (const char *funcname,int cond); +#define audio_bug (funcname, cond) ((cond) ? audio_bug_found (funcname), 1 : 0) +void audio_bug_found (const char *funcname);void *audio_calloc (const char *funcname,int nmemb,size_t size);void audio_run (const char *msg);
[Qemu-devel] Re: [PATCH 6/6] fix audio_bug related failures
Quoted 1 line · Anthony Liguori
What did clang complain about? It's not obvious to me.
It doesn't see that audio_bug returns cond, and gives quite a few false positive in its callers.
Paolo
Re: [Qemu-devel] Re: [PATCH 6/6] fix audio_bug related failures
Quoted 4 lines · Paolo Bonzini
Quoted 1 line · Anthony Liguori
What did clang complain about? It's not obvious to me.
It doesn't see that
audio_bugreturns cond, and gives quite a few false positive in its callers.
Ah, this is a clang issue. I'll have to defer to malc on this one.
Regards,
Anthony Liguori
Quoted 5 lines
Paolo
Re: [Qemu-devel] Re: [PATCH 6/6] fix audio_bug related failures
Quoted 9 lines · Anthony Liguori
Quoted 5 lines · Paolo Bonzini
Quoted 1 line · Anthony Liguori
What did clang complain about? It's not obvious to me.
It doesn't see that
audio_bugreturns cond, and gives quite a few false positive in its callers.Ah, this is a clang issue. I'll have to defer to malc on this one.
I'm against it.
Signature · 1 line
mailto:[email protected]
[Qemu-devel] Re: [PATCH 6/6] fix audio_bug related failures
Quoted 4 lines · malc
Quoted 2 lines · Anthony Liguori
Quoted 1 line · Paolo Bonzini
On 01/27/2010 03:10 AM, Anthony Liguori wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
What did clang complain about? It's not obvious to me.
It doesn't see that
audio_bugreturns cond, and gives quite a few false positive in its callers.Ah, this is a clang issue. I'll have to defer to malc on this one.
I'm against it.
Ok, I'll withdraw this patch. I already posted v2.
Paolo
Quoted 4 lines · Paolo Bonzini
All of these should be quite uncontroversial. The
vnc.cchange is not what you'd expect though (could be a real bug, so I leave the clang warning).
I'm scratching my head quite a bit on these. Can you resend the series with commit messages that actually explain what the problem clang is reporting and why it fixes it.
The vnc one is just whacky.
Regards,
Anthony Liguori