[libvirt] [PATCH] beautify code indent in qemu migration

Signed-off-by: liguang <lig.fnst@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); - 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); - 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) 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))) { virReportError(VIR_ERR_OPERATION_INVALID, _("cannot migrate domain with %d snapshots"), nsnapshots); -- 1.7.1

On 2012年11月16日 11:27, liguang wrote:
Signed-off-by: liguang<lig.fnst@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.
- 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.
virReportError(VIR_ERR_OPERATION_INVALID, _("cannot migrate domain with %d snapshots"), nsnapshots);
Regards, Osier

在 2012-11-16五的 12:51 +0800,Osier Yang写道:
On 2012年11月16日 11:27, liguang wrote:
Signed-off-by: liguang<lig.fnst@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?
- 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
virReportError(VIR_ERR_OPERATION_INVALID, _("cannot migrate domain with %d snapshots"), nsnapshots);
Regards, Osier
-- li guang lig.fnst@cn.fujitsu.com linux kernel team at FNST, china

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@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

On Fri, Nov 16, 2012 at 12:51:46PM +0800, Osier Yang wrote:
On 2012年11月16日 11:27, liguang wrote:
Signed-off-by: liguang<lig.fnst@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.
I say if it is not over 80 chars, then keeping it all on one line is nice. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (4)
-
Daniel P. Berrange
-
li guang
-
liguang
-
Osier Yang