]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu/qemu_migration_params: use virStringParseYesNo helper
authorMao Zhongyi <maozhongyi@cmss.chinamobile.com>
Thu, 17 Oct 2019 03:19:33 +0000 (11:19 +0800)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Nov 2019 13:14:50 +0000 (08:14 -0500)
A function virStringParseYesNo was added to convert
string 'yes' to true and 'no' to false, so use this
helper to replace 'STREQ(.*, \"yes\")' and
'STREQ(.*, \"no\")' as it allows us to drop several
repetitive if-then-else string->bool conversion blocks.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
src/qemu/qemu_migration_params.c

index dca12033c03ecb682de2a15206f840783b3771f0..c28814bc5b219b9ca2d113276546ba70697575c4 100644 (file)
@@ -1319,12 +1319,7 @@ qemuMigrationParamsParse(xmlXPathContextPtr ctxt,
             break;
 
         case QEMU_MIGRATION_PARAM_TYPE_BOOL:
-            if (STREQ(value, "yes"))
-                pv->value.b = true;
-            else if (STREQ(value, "no"))
-                pv->value.b = false;
-            else
-                rc = -1;
+            rc = virStringParseYesNo(value, &pv->value.b);
             break;
 
         case QEMU_MIGRATION_PARAM_TYPE_STRING: