[libvirt PATCH 1/4] vbox: use g_new0 in vboxDumpAudio

Ján Tomko posted 4 patches 5 years, 4 months ago
[libvirt PATCH 1/4] vbox: use g_new0 in vboxDumpAudio
Posted by Ján Tomko 5 years, 4 months ago
Elimination of the positive conditions reduces
the indentation by two levels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/vbox/vbox_common.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 9f6ef2f2ac..45fd670a11 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -3798,20 +3798,16 @@ vboxDumpAudio(virDomainDefPtr def, vboxDriverPtr data G_GNUC_UNUSED,
             PRUint32 audioController = AudioControllerType_AC97;
 
             def->nsounds = 1;
-            if (VIR_ALLOC_N(def->sounds, def->nsounds) >= 0) {
-                if (VIR_ALLOC(def->sounds[0]) >= 0) {
-                    gVBoxAPI.UIAudioAdapter.GetAudioController(audioAdapter, &audioController);
-                    if (audioController == AudioControllerType_SB16) {
-                        def->sounds[0]->model = VIR_DOMAIN_SOUND_MODEL_SB16;
-                    } else if (audioController == AudioControllerType_AC97) {
-                        def->sounds[0]->model = VIR_DOMAIN_SOUND_MODEL_AC97;
-                    }
-                } else {
-                    VIR_FREE(def->sounds);
-                    def->nsounds = 0;
-                }
-            } else {
-                def->nsounds = 0;
+            if (VIR_ALLOC_N(def->sounds, def->nsounds) < 0)
+                return;
+            if (VIR_ALLOC(def->sounds[0]) < 0)
+                return;
+
+            gVBoxAPI.UIAudioAdapter.GetAudioController(audioAdapter, &audioController);
+            if (audioController == AudioControllerType_SB16) {
+                def->sounds[0]->model = VIR_DOMAIN_SOUND_MODEL_SB16;
+            } else if (audioController == AudioControllerType_AC97) {
+                def->sounds[0]->model = VIR_DOMAIN_SOUND_MODEL_AC97;
             }
         }
         VBOX_RELEASE(audioAdapter);
-- 
2.26.2

Re: [libvirt PATCH 1/4] vbox: use g_new0 in vboxDumpAudio
Posted by Erik Skultety 5 years, 4 months ago
On Mon, Oct 05, 2020 at 12:22:23AM +0200, Ján Tomko wrote:
> Elimination of the positive conditions reduces
> the indentation by two levels.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---

No g_new0 was introduced by this commit, so the subject should be adjusted to
reflect the true nature of the patch.

Reviewed-by: Erik Skultety <eskultet@redhat.com>