]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xenconfig: Move guts of xenFormatSxprSound into xenFormatSound
authorPeter Krempa <pkrempa@redhat.com>
Wed, 3 Jul 2019 07:04:01 +0000 (09:04 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 9 Jul 2019 08:27:19 +0000 (10:27 +0200)
Use new coding style to merge the only use of xenFormatSxprSound into
the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_xenconfig.syms
src/xenconfig/xen_common.c
src/xenconfig/xen_sxpr.c
src/xenconfig/xen_sxpr.h

index 945f16e382416c372aebe359c75c23e1ef61d79f..e9fab0a8d0aad5c64527a7c87eb6fcd261e77532 100644 (file)
@@ -4,7 +4,6 @@
 
 # xenconfig/xen_sxpr.h
 xenFormatSxprChr;
-xenFormatSxprSound;
 xenGetDomIdFromSxpr;
 xenGetDomIdFromSxprString;
 xenParseSxpr;
index 69a6f53507613212b6646c65a1141a2cd4b03274..059bf785bb5e53199dc9f64791ea9228405faee2 100644 (file)
@@ -2006,25 +2006,34 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def)
 static int
 xenFormatSound(virConfPtr conf, virDomainDefPtr def)
 {
-    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
-        if (def->sounds) {
-            virBuffer buf = VIR_BUFFER_INITIALIZER;
-            char *str = NULL;
-            int ret = xenFormatSxprSound(def, &buf);
+    VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+    const char * model;
+    VIR_AUTOFREE(char *) str = NULL;
+    size_t i;
 
-            str = virBufferContentAndReset(&buf);
-            if (ret == 0)
-                ret = xenConfigSetString(conf, "soundhw", str);
+    if (def->os.type != VIR_DOMAIN_OSTYPE_HVM ||
+        !def->sounds)
+        return 0;
 
-            VIR_FREE(str);
-            if (ret < 0)
-                return -1;
+    for (i = 0; i < def->nsounds; i++) {
+        if (!(model = virDomainSoundModelTypeToString(def->sounds[i]->model))) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("unexpected sound model %d"),
+                           def->sounds[i]->model);
+            return -1;
         }
+        if (i)
+            virBufferAddChar(&buf, ',');
+        virBufferEscapeSexpr(&buf, "%s", model);
     }
 
-    return 0;
-}
+    if (virBufferCheckError(&buf) < 0)
+        return -1;
 
+    str = virBufferContentAndReset(&buf);
+
+    return xenConfigSetString(conf, "soundhw", str);
+}
 
 
 static int
index d67a89efee474e61a5c71c6ec8f6c2cfd1eba67a..3a1c912963d8c74f3854e7c1f01c6f638a02aa31 100644 (file)
@@ -1569,38 +1569,3 @@ xenFormatSxprChr(virDomainChrDefPtr def,
 
     return 0;
 }
-
-
-/**
- * xenFormatSxprSound:
- * @def: the domain config
- * @buf: a buffer for the result S-expression
- *
- * Convert all sound device parts of the domain config into S-expression in buf.
- *
- * Returns 0 if successful or -1 if failed.
- */
-int
-xenFormatSxprSound(virDomainDefPtr def,
-                   virBufferPtr buf)
-{
-    const char *str;
-    size_t i;
-
-    for (i = 0; i < def->nsounds; i++) {
-        if (!(str = virDomainSoundModelTypeToString(def->sounds[i]->model))) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unexpected sound model %d"),
-                           def->sounds[i]->model);
-            return -1;
-        }
-        if (i)
-            virBufferAddChar(buf, ',');
-        virBufferEscapeSexpr(buf, "%s", str);
-    }
-
-    if (virBufferCheckError(buf) < 0)
-        return -1;
-
-    return 0;
-}
index 93af9815449df8fe1c4ad44b0535d2ad3de09f7b..7f66af64059322546e975c8f465f07037121f858 100644 (file)
@@ -51,4 +51,3 @@ virDomainChrDefPtr xenParseSxprChar(const char *value, const char *tty);
 int xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec);
 
 int xenFormatSxprChr(virDomainChrDefPtr def, virBufferPtr buf);
-int xenFormatSxprSound(virDomainDefPtr def, virBufferPtr buf);