diff mbox

[11/12] audio: Clean up inappropriate and unreachable use of hw_error()

Message ID 1449743372-17169-12-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Dec. 10, 2015, 10:29 a.m. UTC
audio_init() should not use hw_error(), because dumping CPU registers
is unhelpful there, and aborting is wrong, because it can be called
called from an audio device's realize() method.

The two uses of hw_error() come from commit 0d9acba:

* When qemu_new_timer() fails.  It couldn't fail back then, and it
  can't fail now.  Drop the unreachable error handling.

* When no_audio_driver can't be initialized.  It couldn't fail back
  then, and it can't fail now.  Replace the error handling by an
  assertion.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 audio/audio.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comments

Gerd Hoffmann Dec. 15, 2015, 10:07 a.m. UTC | #1
On Do, 2015-12-10 at 11:29 +0100, Markus Armbruster wrote:
> audio_init() should not use hw_error(), because dumping CPU registers
> is unhelpful there, and aborting is wrong, because it can be called
> called from an audio device's realize() method.
> 
> The two uses of hw_error() come from commit 0d9acba:
> 
> * When qemu_new_timer() fails.  It couldn't fail back then, and it
>   can't fail now.  Drop the unreachable error handling.
> 
> * When no_audio_driver can't be initialized.  It couldn't fail back
>   then, and it can't fail now.  Replace the error handling by an
>   assertion.
> 
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

> ---
>  audio/audio.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/audio/audio.c b/audio/audio.c
> index 5be4b15..9b855ed 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -1806,9 +1806,6 @@ static void audio_init (void)
>      atexit (audio_atexit);
>  
>      s->ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s);
> -    if (!s->ts) {
> -        hw_error("Could not create audio timer\n");
> -    }
>  
>      audio_process_options ("AUDIO", audio_options);
>  
> @@ -1859,12 +1856,8 @@ static void audio_init (void)
>  
>      if (!done) {
>          done = !audio_driver_init (s, &no_audio_driver);
> -        if (!done) {
> -            hw_error("Could not initialize audio subsystem\n");
> -        }
> -        else {
> -            dolog ("warning: Using timer based audio emulation\n");
> -        }
> +        assert(done);
> +        dolog ("warning: Using timer based audio emulation\n");
>      }
>  
>      if (conf.period.hertz <= 0) {
diff mbox

Patch

diff --git a/audio/audio.c b/audio/audio.c
index 5be4b15..9b855ed 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1806,9 +1806,6 @@  static void audio_init (void)
     atexit (audio_atexit);
 
     s->ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s);
-    if (!s->ts) {
-        hw_error("Could not create audio timer\n");
-    }
 
     audio_process_options ("AUDIO", audio_options);
 
@@ -1859,12 +1856,8 @@  static void audio_init (void)
 
     if (!done) {
         done = !audio_driver_init (s, &no_audio_driver);
-        if (!done) {
-            hw_error("Could not initialize audio subsystem\n");
-        }
-        else {
-            dolog ("warning: Using timer based audio emulation\n");
-        }
+        assert(done);
+        dolog ("warning: Using timer based audio emulation\n");
     }
 
     if (conf.period.hertz <= 0) {