[libvirt] [PATCH] beautify code indent in qemu migration
Osier Yang
jyang at redhat.com
Fri Nov 16 07:49:35 UTC 2012
On 2012年11月16日 13:11, li guang wrote:
> 在 2012-11-16五的 12:51 +0800,Osier Yang写道:
>> On 2012年11月16日 11:27, liguang wrote:
>>> Signed-off-by: liguang<lig.fnst at cn.fujitsu.com>
>>> ---
>>> src/qemu/qemu_migration.c | 18 ++++++------------
>>> 1 files changed, 6 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
>>> index 716365f..0e00cac 100644
>>> --- a/src/qemu/qemu_migration.c
>>> +++ b/src/qemu/qemu_migration.c
>>> @@ -692,12 +692,10 @@ qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
>>> qemuMigrationCookieFlagTypeToString(i));
>>> }
>>>
>>> - if ((mig->flags& QEMU_MIGRATION_COOKIE_GRAPHICS)&&
>>> - mig->graphics)
>>> + if ((mig->flags& QEMU_MIGRATION_COOKIE_GRAPHICS)&& mig->graphics)
>>> qemuMigrationCookieGraphicsXMLFormat(buf, mig->graphics);
>>
>> Things like this is really personal favor I think.
>
> it's clear that "if statement" can be placed one line,
> why a new line is acceptable?
> don't you think it's more beautiful and tidier?
I just can live with the old ones.
>
>>>
>>> - if ((mig->flags& QEMU_MIGRATION_COOKIE_LOCKSTATE)&&
>>> - mig->lockState) {
>>> + if ((mig->flags& QEMU_MIGRATION_COOKIE_LOCKSTATE)&& mig->lockState) {
>>> virBufferAsprintf(buf, "<lockstate driver='%s'>\n",
>>> mig->lockDriver);
>>> virBufferAsprintf(buf, "<leases>%s</leases>\n",
>>> @@ -705,8 +703,7 @@ qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
>>> virBufferAddLit(buf, "</lockstate>\n");
>>> }
>>>
>>> - if ((mig->flags& QEMU_MIGRATION_COOKIE_PERSISTENT)&&
>>> - mig->persistent) {
>>> + if ((mig->flags& QEMU_MIGRATION_COOKIE_PERSISTENT)&& mig->persistent) {
>>> virBufferAdjustIndent(buf, 2);
>>> if (qemuDomainDefFormatBuf(driver,
>>> mig->persistent,
>>> @@ -790,7 +787,6 @@ qemuMigrationCookieGraphicsXMLParse(xmlXPathContextPtr ctxt)
>>> /* Optional */
>>> grap->tlsSubject = virXPathString("string(./graphics/cert[@info='subject']/@value)", ctxt);
>>>
>>> -
>>
>> This is good though.
>>
>>> return grap;
>>>
>>> no_memory:
>>> @@ -821,7 +817,7 @@ qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt)
>>> }
>>>
>>> optr->nnets = n;
>>> - if (VIR_ALLOC_N(optr->net, optr->nnets)<0)
>>> + if (VIR_ALLOC_N(optr->net, optr->nnets)< 0)
>>
>> Good too.
>>
>>> goto no_memory;
>>>
>>> for (i = 0; i< n; i++) {
>>> @@ -1137,8 +1133,7 @@ qemuMigrationEatCookie(struct qemud_driver *driver,
>>> qemuMigrationCookiePtr mig = NULL;
>>>
>>> /* Parse& validate incoming cookie (if any) */
>>> - if (cookiein&& cookieinlen&&
>>> - cookiein[cookieinlen-1] != '\0') {
>>> + if (cookiein&& cookieinlen&& cookiein[cookieinlen-1] != '\0') {
>>> virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>>> _("Migration cookie was not NULL terminated"));
>>> goto error;
>>> @@ -1204,8 +1199,7 @@ qemuMigrationIsAllowed(struct qemud_driver *driver, virDomainObjPtr vm,
>>> "%s", _("domain is marked for auto destroy"));
>>> return false;
>>> }
>>> - if ((nsnapshots = virDomainSnapshotObjListNum(vm->snapshots, NULL,
>>> - 0))) {
>>> + if ((nsnapshots = virDomainSnapshotObjListNum(vm->snapshots, NULL, 0))) {
>>
>> More than 80 chars.
>
> 74 chars
It's 74 chars, but before your modification.
>
>>> virReportError(VIR_ERR_OPERATION_INVALID,
>>> _("cannot migrate domain with %d snapshots"),
>>> nsnapshots);
>>
>>
>> Regards,
>> Osier
>
More information about the libvir-list
mailing list