[libvirt] [PATCH 0/4] cfg.mk: Introduce syntax-check rule for incorrect indentation or empty line in function body

This series introduce syntax-check rule for below: 1. For incorrect indentation of the first line in function body int foo(int a0, ...) { [NOT 4 spaces]int first-line; ... ... } 2. For empty first line of function body int foo(int a0, ...) { [empty line] int second-line; ... ... } And it *ignores* the conditions as below: 1. For macros just as #if/#ifdef int foo(int a0, ...) { #if ANYTHING int second-line; ... ... } 2. For comments int foo(int a0, ...) { /* comments */ int second-line; ... ... } 3. For empty function body int foo(void) { } ^ This function has NO content 4. For labels { readmore: int second-line; ... ... goto readmore; ... ... } Shi Lei (4): cfg.mk: Introduce syntax-check rule for incorrect indentation or empty line in function body src: fix incorrect indentation or empty first line in function body tests: fix incorrect indentation or empty first line in function body tools: fix incorrect indentation or empty first line in function body cfg.mk | 11 +++ src/bhyve/bhyve_command.c | 3 - src/bhyve/bhyve_conf.c | 6 +- src/bhyve/bhyve_driver.c | 33 ++++--- src/bhyve/bhyve_monitor.c | 1 - src/bhyve/bhyve_process.c | 1 - src/conf/cpu_conf.c | 1 - src/conf/domain_capabilities.c | 1 - src/conf/domain_conf.c | 12 +-- src/conf/network_conf.c | 2 - src/cpu/cpu_s390.c | 82 ++++++++--------- src/cpu/cpu_x86.c | 1 - src/esx/esx_vi_types.c | 2 +- src/locking/lock_driver_nop.c | 1 - src/network/bridge_driver.c | 1 - src/network/bridge_driver_linux.c | 1 - src/nwfilter/nwfilter_learnipaddr.c | 1 - src/phyp/phyp_driver.c | 1 - src/qemu/qemu_alias.c | 1 - src/qemu/qemu_domain_address.c | 1 - src/qemu/qemu_driver.c | 1 - src/qemu/qemu_monitor.c | 1 - src/qemu/qemu_monitor_json.c | 1 - src/qemu/qemu_process.c | 1 - src/storage/storage_backend_sheepdog.c | 3 - src/storage/storage_driver.c | 1 - src/storage/storage_util.c | 1 - src/test/test_driver.c | 2 - src/util/vircommand.c | 6 +- src/util/virdbuspriv.h | 18 ++-- src/util/virdnsmasq.c | 1 - src/util/virfile.c | 1 - src/util/virnetdev.c | 55 ++++++------ src/util/virnetdevmacvlan.c | 11 ++- src/util/virnetdevvportprofile.c | 2 +- src/util/virstoragefile.c | 1 - src/util/virutil.c | 3 +- src/vbox/vbox_storage.c | 1 - src/vz/vz_driver.c | 1 - src/vz/vz_sdk.c | 1 - src/xenapi/xenapi_driver.c | 2 - src/xenconfig/xen_common.c | 9 +- tests/qemuxml2argvmock.c | 2 +- tests/sexpr2xmltest.c | 30 +++---- tests/virnetdevmock.c | 1 - tests/virnettlshelpers.c | 18 ++-- tests/virshtest.c | 118 ++++++++++++------------- tests/vshtabletest.c | 3 - tests/xml2sexprtest.c | 24 ++--- tools/virsh-volume.c | 1 - tools/virt-admin.c | 1 - 51 files changed, 218 insertions(+), 266 deletions(-) -- 2.17.1

Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- cfg.mk | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cfg.mk b/cfg.mk index 609ae86..a43cb1c 100644 --- a/cfg.mk +++ b/cfg.mk @@ -702,6 +702,17 @@ sc_preprocessor_indentation: echo '$(ME): skipping test $@: cppi not installed' 1>&2; \ fi +# Use 4 spaces rather than TAB for indentation for those top-level +# function bodies. Doesn't catch all cases, but it helps. +sc_indentation_for_function_body: + @for f in $$($(VC_LIST_EXCEPT) | grep -E '\.[ch](\.in)?$$'); do \ + grep -n -A1 '^{$$' $$f | grep '^[0-9]\{1,\}-' \ + | grep -v '^[0-9]\{1,\}-[ ]\{4\}\S' | grep -v '^[0-9]\{1,\}-\([#}/]\|.*:\)' \ + | $(SED) -ne "s#\(^[0-9]\{1,\}\)-#$$f:\1:#gp" | grep . && \ + { echo '$(ME): incorrect indentation or empty for first line in function body' 1>&2; \ + exit 1; } \ + done || : + # Enforce similar spec file indentation style, by running cppi on a # (comment-only) C file that mirrors the same layout as the spec file. sc_spec_indentation: -- 2.17.1

On Wed, Sep 12, 2018 at 11:58:20AM +0800, Shi Lei wrote:
Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- cfg.mk | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/cfg.mk b/cfg.mk index 609ae86..a43cb1c 100644 --- a/cfg.mk +++ b/cfg.mk @@ -702,6 +702,17 @@ sc_preprocessor_indentation: echo '$(ME): skipping test $@: cppi not installed' 1>&2; \ fi
+# Use 4 spaces rather than TAB for indentation for those top-level +# function bodies. Doesn't catch all cases, but it helps. +sc_indentation_for_function_body: + @for f in $$($(VC_LIST_EXCEPT) | grep -E '\.[ch](\.in)?$$'); do \
Doing it this way is very inefficient. This spawns 5 greps and one sed for each .c file. It might be bearable for spec files, when we only have two, but we have nearly a thousand .c and .h files I spent quite some time on making syntax-check as fast as possible, to encourage people to run it more often. Adding this to build-aux/check-spacing.pl would let you take advantage of the existing code for opening the files and get rid of all the line number regexes, making the check more readable. Also, it would let you split the error message and only output the relevant one. Grouping indentation and empty lines in one error message is not very friendly.
+ grep -n -A1 '^{$$' $$f | grep '^[0-9]\{1,\}-' \ + | grep -v '^[0-9]\{1,\}-[ ]\{4\}\S' |
grep -v '^[0-9]\{1,\}-\([#}/]\|.*:\)' \
There is no need to exempt '/', the following is also wrong: src/qemu/qemu_domain_address.c:2303:/* Try to find a nice default for busNr for a new pci-expander-bus. Jano
+ | $(SED) -ne "s#\(^[0-9]\{1,\}\)-#$$f:\1:#gp" | grep . && \ + { echo '$(ME): incorrect indentation or empty for first line in function body' 1>&2; \ + exit 1; } \ + done || : + # Enforce similar spec file indentation style, by running cppi on a # (comment-only) C file that mirrors the same layout as the spec file. sc_spec_indentation: -- 2.17.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 2018-09-12 at 19:58, Ján Tomko wrote:
On Wed, Sep 12, 2018 at 11:58:20AM +0800, Shi Lei wrote:
Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- cfg.mk | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/cfg.mk b/cfg.mk index 609ae86..a43cb1c 100644 --- a/cfg.mk +++ b/cfg.mk @@ -702,6 +702,17 @@ sc_preprocessor_indentation: echo '$(ME): skipping test $@: cppi not installed' 1>&2; \ fi
+# Use 4 spaces rather than TAB for indentation for those top-level +# function bodies. Doesn't catch all cases, but it helps. +sc_indentation_for_function_body: + @for f in $$($(VC_LIST_EXCEPT) | grep -E '\.[ch](\.in)?$$'); do \
Doing it this way is very inefficient. This spawns 5 greps and one sed for each .c file. It might be bearable for spec files, when we only have two, but we have nearly a thousand .c and .h files
I spent quite some time on making syntax-check as fast as possible, to encourage people to run it more often.
Adding this to build-aux/check-spacing.pl would let you take advantage of the existing code for opening the files and get rid of all the line number regexes, making the check more readable.
Also, it would let you split the error message and only output the relevant one. Grouping indentation and empty lines in one error message is not very friendly.
Okay, I see.
+ grep -n -A1 '^{$$' $$f | grep '^[0-9]\{1,\}-' \ + | grep -v '^[0-9]\{1,\}-[ ]\{4\}\S' |
grep -v '^[0-9]\{1,\}-\([#}/]\|.*:\)' \
There is no need to exempt '/', the following is also wrong: src/qemu/qemu_domain_address.c:2303:/* Try to find a nice default for busNr for a new pci-expander-bus.
Okay.
Jano
Thanks for your directions, Shi Lei
+ | $(SED) -ne "s#\(^[0-9]\{1,\}\)-#$$f:\1:#gp" | grep . && \ + { echo '$(ME): incorrect indentation or empty for first line in function body' 1>&2; \ + exit 1; } \ + done || : + # Enforce similar spec file indentation style, by running cppi on a # (comment-only) C file that mirrors the same layout as the spec file. sc_spec_indentation: -- 2.17.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/bhyve/bhyve_command.c | 3 - src/bhyve/bhyve_conf.c | 6 +- src/bhyve/bhyve_driver.c | 33 +++++------ src/bhyve/bhyve_monitor.c | 1 - src/bhyve/bhyve_process.c | 1 - src/conf/cpu_conf.c | 1 - src/conf/domain_capabilities.c | 1 - src/conf/domain_conf.c | 12 +--- src/conf/network_conf.c | 2 - src/cpu/cpu_s390.c | 82 +++++++++++++------------- src/cpu/cpu_x86.c | 1 - src/esx/esx_vi_types.c | 2 +- src/locking/lock_driver_nop.c | 1 - src/network/bridge_driver.c | 1 - src/network/bridge_driver_linux.c | 1 - src/nwfilter/nwfilter_learnipaddr.c | 1 - src/phyp/phyp_driver.c | 1 - src/qemu/qemu_alias.c | 1 - src/qemu/qemu_domain_address.c | 1 - src/qemu/qemu_driver.c | 1 - src/qemu/qemu_monitor.c | 1 - src/qemu/qemu_monitor_json.c | 1 - src/qemu/qemu_process.c | 1 - src/storage/storage_backend_sheepdog.c | 3 - src/storage/storage_driver.c | 1 - src/storage/storage_util.c | 1 - src/test/test_driver.c | 2 - src/util/vircommand.c | 6 +- src/util/virdbuspriv.h | 18 +++--- src/util/virdnsmasq.c | 1 - src/util/virfile.c | 1 - src/util/virnetdev.c | 55 ++++++++--------- src/util/virnetdevmacvlan.c | 11 ++-- src/util/virnetdevvportprofile.c | 2 +- src/util/virstoragefile.c | 1 - src/util/virutil.c | 3 +- src/vbox/vbox_storage.c | 1 - src/vz/vz_driver.c | 1 - src/vz/vz_sdk.c | 1 - src/xenapi/xenapi_driver.c | 2 - src/xenconfig/xen_common.c | 9 ++- 41 files changed, 111 insertions(+), 164 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 802997b..6149c93 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -147,7 +147,6 @@ bhyveBuildNetArgStr(virConnectPtr conn, static int bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd) { - virDomainChrDefPtr chr = NULL; if (!def->nserials) @@ -710,7 +709,6 @@ virBhyveProcessBuildCustomLoaderCmd(virDomainDefPtr def) static bool virBhyveUsableDisk(virDomainDiskDefPtr disk) { - if (virDomainDiskTranslateSourcePool(disk) < 0) return false; @@ -734,7 +732,6 @@ virBhyveUsableDisk(virDomainDiskDefPtr disk) static void virBhyveFormatGrubDevice(virBufferPtr devicemap, virDomainDiskDefPtr def) { - if (def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) virBufferAsprintf(devicemap, "(cd) %s\n", virDomainDiskGetSource(def)); diff --git a/src/bhyve/bhyve_conf.c b/src/bhyve/bhyve_conf.c index 153de7b..60baa2e 100644 --- a/src/bhyve/bhyve_conf.c +++ b/src/bhyve/bhyve_conf.c @@ -36,10 +36,10 @@ static void virBhyveDriverConfigDispose(void *obj); static int virBhyveConfigOnceInit(void) { - if (!VIR_CLASS_NEW(virBhyveDriverConfig, virClassForObject())) - return -1; + if (!VIR_CLASS_NEW(virBhyveDriverConfig, virClassForObject())) + return -1; - return 0; + return 0; } VIR_ONCE_GLOBAL_INIT(virBhyveConfig) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 9284b51..4d4f85f 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -133,7 +133,6 @@ bhyveAutostartDomains(bhyveConnPtr driver) virCapsPtr ATTRIBUTE_NONNULL(1) bhyveDriverGetCapabilities(bhyveConnPtr driver) { - return virObjectRef(driver->caps); } @@ -197,27 +196,27 @@ bhyveConnectOpen(virConnectPtr conn, virConfPtr conf ATTRIBUTE_UNUSED, unsigned int flags) { - virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected bhyve URI path '%s', try bhyve:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected bhyve URI path '%s', try bhyve:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } - if (bhyve_driver == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("bhyve state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + if (bhyve_driver == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("bhyve state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } - if (virConnectOpenEnsureACL(conn) < 0) - return VIR_DRV_OPEN_ERROR; + if (virConnectOpenEnsureACL(conn) < 0) + return VIR_DRV_OPEN_ERROR; - conn->privateData = bhyve_driver; + conn->privateData = bhyve_driver; - return VIR_DRV_OPEN_SUCCESS; + return VIR_DRV_OPEN_SUCCESS; } static int diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index 8524834..4d5262c 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -177,7 +177,6 @@ bhyveMonitorOpen(virDomainObjPtr vm, bhyveConnPtr driver) void bhyveMonitorClose(bhyveMonitorPtr mon) { - if (mon == NULL) return; diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 9276d7d..4dab6e5 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -89,7 +89,6 @@ bhyveNetCleanup(virDomainObjPtr vm) static int virBhyveFormatDevMapFile(const char *vm_name, char **fn_out) { - return virAsprintf(fn_out, "%s/grub_bhyve-%s-device.map", BHYVE_STATE_DIR, vm_name); } diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 43a3ab5..863413e 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -87,7 +87,6 @@ virCPUDefFreeFeatures(virCPUDefPtr def) void ATTRIBUTE_NONNULL(1) virCPUDefFreeModel(virCPUDefPtr def) { - VIR_FREE(def->model); VIR_FREE(def->vendor); VIR_FREE(def->vendor_id); diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index d3d108a..3b87bdf 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -559,7 +559,6 @@ static void virDomainCapsFeatureSEVFormat(virBufferPtr buf, virSEVCapabilityPtr const sev) { - if (!sev) { virBufferAddLit(buf, "<sev supported='no'/>\n"); } else { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7e14cea..6e7f623 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -989,7 +989,6 @@ static int virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap, xmlNodePtr node) { - char *name = NULL; char *state = NULL; int state_type; @@ -6909,7 +6908,6 @@ static int virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, virDomainHostdevDefPtr def) { - int ret = -1; bool got_product, got_vendor; xmlNodePtr cur; @@ -12147,7 +12145,6 @@ virDomainChrSourceDefParseUnix(virDomainChrSourceDefPtr def, xmlNodePtr source, xmlXPathContextPtr ctxt) { - int mode; if ((mode = virDomainChrSourceDefParseMode(source)) < 0) @@ -14198,7 +14195,6 @@ virDomainWatchdogDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, unsigned int flags) { - char *model = NULL; char *action = NULL; virDomainWatchdogDefPtr def; @@ -14439,7 +14435,7 @@ virDomainNVRAMDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, unsigned int flags) { - virDomainNVRAMDefPtr def; + virDomainNVRAMDefPtr def; if (VIR_ALLOC(def) < 0) return NULL; @@ -16295,7 +16291,6 @@ virDomainChrTargetTypeToString(int deviceType, int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev) { - return VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev); } @@ -16634,7 +16629,6 @@ virDomainDiskByName(virDomainDefPtr def, int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk) { - if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) return -1; @@ -16850,7 +16844,6 @@ virDomainNetRemove(virDomainDefPtr def, size_t i) int virDomainControllerInsert(virDomainDefPtr def, virDomainControllerDefPtr controller) { - if (VIR_REALLOC_N(def->controllers, def->ncontrollers+1) < 0) return -1; @@ -17067,7 +17060,6 @@ void virDomainLeaseInsertPreAlloced(virDomainDefPtr def, virDomainLeaseDefPtr virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i) { - virDomainLeaseDefPtr lease = def->leases[i]; VIR_DELETE_ELEMENT(def->leases, i, def->nleases); @@ -28656,7 +28648,6 @@ virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, int *busIdx, int *devIdx) { - int idx = virDiskNameToIndex(disk->dst); if (idx < 0) return -1; @@ -28687,7 +28678,6 @@ virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs) { - return VIR_APPEND_ELEMENT(def->fss, def->nfss, fs); } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index c08456b..5372aff 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -355,8 +355,6 @@ virSocketAddrRangeParseXML(const char *networkName, xmlNodePtr node, virSocketAddrRangePtr range) { - - char *start = NULL, *end = NULL; int ret = -1; diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c index 3d10f92..99adb37 100644 --- a/src/cpu/cpu_s390.c +++ b/src/cpu/cpu_s390.c @@ -48,50 +48,50 @@ static int virCPUs390Update(virCPUDefPtr guest, const virCPUDef *host) { - virCPUDefPtr updated = NULL; - int ret = -1; - size_t i; - - if (guest->match == VIR_CPU_MATCH_MINIMUM) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("match mode %s not supported"), - virCPUMatchTypeToString(guest->match)); - goto cleanup; - } - - if (guest->mode != VIR_CPU_MODE_HOST_MODEL) { - ret = 0; - goto cleanup; - } - - if (!host) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unknown host CPU model")); - goto cleanup; - } - - if (!(updated = virCPUDefCopyWithoutModel(guest))) - goto cleanup; - - updated->mode = VIR_CPU_MODE_CUSTOM; - if (virCPUDefCopyModel(updated, host, true) < 0) - goto cleanup; - - for (i = 0; i < guest->nfeatures; i++) { - if (virCPUDefUpdateFeature(updated, - guest->features[i].name, - guest->features[i].policy) < 0) - goto cleanup; - } - - virCPUDefStealModel(guest, updated, false); - guest->mode = VIR_CPU_MODE_CUSTOM; - guest->match = VIR_CPU_MATCH_EXACT; + virCPUDefPtr updated = NULL; + int ret = -1; + size_t i; + + if (guest->match == VIR_CPU_MATCH_MINIMUM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("match mode %s not supported"), + virCPUMatchTypeToString(guest->match)); + goto cleanup; + } + + if (guest->mode != VIR_CPU_MODE_HOST_MODEL) { ret = 0; + goto cleanup; + } + + if (!host) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unknown host CPU model")); + goto cleanup; + } + + if (!(updated = virCPUDefCopyWithoutModel(guest))) + goto cleanup; + + updated->mode = VIR_CPU_MODE_CUSTOM; + if (virCPUDefCopyModel(updated, host, true) < 0) + goto cleanup; + + for (i = 0; i < guest->nfeatures; i++) { + if (virCPUDefUpdateFeature(updated, + guest->features[i].name, + guest->features[i].policy) < 0) + goto cleanup; + } + + virCPUDefStealModel(guest, updated, false); + guest->mode = VIR_CPU_MODE_CUSTOM; + guest->match = VIR_CPU_MATCH_EXACT; + ret = 0; cleanup: - virCPUDefFree(updated); - return ret; + virCPUDefFree(updated); + return ret; } diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index cb27550..4770850 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -463,7 +463,6 @@ static bool x86DataIsSubset(const virCPUx86Data *data, const virCPUx86Data *subset) { - virCPUx86DataIterator iter = virCPUx86DataIteratorInit((virCPUx86Data *)subset); const virCPUx86CPUID *cpuid; const virCPUx86CPUID *cpuidSubset; diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 7b234f0..a21a329 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -1781,7 +1781,7 @@ ESX_VI__TEMPLATE__LIST__APPEND(Event) /* esxVI_Event_CastFromAnyType */ ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(Event, { - case esxVI_Type_Other: + case esxVI_Type_Other: /* Just accept everything here */ break; }) diff --git a/src/locking/lock_driver_nop.c b/src/locking/lock_driver_nop.c index b5eb295..227195f 100644 --- a/src/locking/lock_driver_nop.c +++ b/src/locking/lock_driver_nop.c @@ -63,7 +63,6 @@ static int virLockManagerNopAddResource(virLockManagerPtr lock ATTRIBUTE_UNUSED, virLockManagerParamPtr params ATTRIBUTE_UNUSED, unsigned int flags_unused ATTRIBUTE_UNUSED) { - return 0; } diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 588b0d1..3e2eac2 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3237,7 +3237,6 @@ static int networkFindUnusedBridgeName(virNetworkObjListPtr nets, virNetworkDefPtr def) { - int ret = -1, id = 0; char *newname = NULL; const char *templ = "virbr%d"; diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c index 3effcdc..fb09954 100644 --- a/src/network/bridge_driver_linux.c +++ b/src/network/bridge_driver_linux.c @@ -486,7 +486,6 @@ static void networkAddGeneralIPv6FirewallRules(virFirewallPtr fw, virNetworkDefPtr def) { - if (!virNetworkDefGetIPByIndex(def, AF_INET6, 0) && !def->ipv6nogw) { return; diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index 6965af2..008c24b 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -796,7 +796,6 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED, int virNWFilterLearnInit(void) { - if (pendingLearnReq) return 0; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 28a1fa3..faa35a6 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3652,7 +3652,6 @@ phypDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) static int phypDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) { - phyp_driverPtr phyp_driver = dom->conn->privateData; LIBSSH2_SESSION *session = phyp_driver->session; char *managed_system = phyp_driver->managed_system; diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 162a4d3..815caec 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -301,7 +301,6 @@ qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx) { - if (net->info.alias) return 0; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 24fdf12..88e2c6e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -915,7 +915,6 @@ qemuDomainFillDevicePCIConnectFlagsIterInit(virDomainDefPtr def, virQEMUDriverPtr driver, qemuDomainFillDevicePCIConnectFlagsIterData *data) { - data->driver = driver; if (qemuDomainHasPCIeRoot(def)) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2f8d691..5c8fd55 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5092,7 +5092,6 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, int maplen, unsigned int flags) { - virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm; virDomainDefPtr def; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 4c0002d..7f7013e 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4121,7 +4121,6 @@ int qemuMonitorGetIOThreads(qemuMonitorPtr mon, qemuMonitorIOThreadInfoPtr **iothreads) { - VIR_DEBUG("iothreads=%p", iothreads); QEMU_CHECK_MONITOR(mon); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3181805..38c30d1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1554,7 +1554,6 @@ int qemuMonitorJSONSetLink(qemuMonitorPtr mon, const char *name, virDomainNetInterfaceLinkState state) { - int ret = -1; virJSONValuePtr reply = NULL; virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("set_link", diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index eb9904b..a06fbf6 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5492,7 +5492,6 @@ int qemuProcessSetupIOThread(virDomainObjPtr vm, virDomainIOThreadIDDefPtr iothread) { - return qemuProcessSetupPid(vm, iothread->thread_id, VIR_CGROUP_THREAD_IOTHREAD, iothread->iothread_id, diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c index 34c118f..419334d 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -216,7 +216,6 @@ virStorageBackendSheepdogDeleteVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags) { - virCheckFlags(0, -1); virCommandPtr cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "delete", vol->name, NULL); @@ -386,7 +385,6 @@ virStorageBackendSheepdogResizeVol(virStoragePoolObjPtr pool, unsigned long long capacity, unsigned int flags) { - virCheckFlags(0, -1); virCommandPtr cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "resize", vol->name, NULL); @@ -396,7 +394,6 @@ virStorageBackendSheepdogResizeVol(virStoragePoolObjPtr pool, virCommandFree(cmd); return ret; - } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 8943df1..c7a7155 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2258,7 +2258,6 @@ virStorageBackendPloopRestoreDesc(char *path) static void virStorageVolPoolRefreshThread(void *opaque) { - virStorageVolStreamInfoPtr cbdata = opaque; virStoragePoolObjPtr obj = NULL; virStoragePoolDefPtr def; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 595edad..ec95817 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -3116,7 +3116,6 @@ virStorageBackendBLKIDFindEmpty(const char *device, const char *format, bool writelabel) { - int ret = -1; int rc; blkid_probe probe = NULL; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c1f31b4..8760bab 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2719,7 +2719,6 @@ static int testConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxnames) { - testDriverPtr privconn = conn->privateData; memset(names, 0, sizeof(*names)*maxnames); @@ -5235,7 +5234,6 @@ testStorageVolDelete(virStorageVolPtr vol, static int testStorageVolumeTypeForPool(int pooltype) { - switch (pooltype) { case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_FS: diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 8be3fdf..9a99275 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2872,10 +2872,10 @@ virCommandFree(virCommandPtr cmd) void virCommandDoAsyncIO(virCommandPtr cmd) { - if (!cmd || cmd->has_error) - return; + if (!cmd || cmd->has_error) + return; - cmd->flags |= VIR_EXEC_ASYNC_IO | VIR_EXEC_NONBLOCK; + cmd->flags |= VIR_EXEC_ASYNC_IO | VIR_EXEC_NONBLOCK; } /** diff --git a/src/util/virdbuspriv.h b/src/util/virdbuspriv.h index 74b395f..6054d59 100644 --- a/src/util/virdbuspriv.h +++ b/src/util/virdbuspriv.h @@ -28,15 +28,15 @@ /* Copied (and simplified) from dbus 1.6.12, for use with older dbus headers */ typedef union { - dbus_int16_t i16; /**< as int16 */ - dbus_uint16_t u16; /**< as int16 */ - dbus_int32_t i32; /**< as int32 */ - dbus_uint32_t u32; /**< as int32 */ - dbus_bool_t bool_val; /**< as boolean */ - dbus_int64_t i64; /**< as int64 */ - dbus_uint64_t u64; /**< as int64 */ - double dbl; /**< as double */ - unsigned char byt; /**< as byte */ + dbus_int16_t i16; /**< as int16 */ + dbus_uint16_t u16; /**< as int16 */ + dbus_int32_t i32; /**< as int32 */ + dbus_uint32_t u32; /**< as int32 */ + dbus_bool_t bool_val; /**< as boolean */ + dbus_int64_t i64; /**< as int64 */ + dbus_uint64_t u64; /**< as int64 */ + double dbl; /**< as double */ + unsigned char byt; /**< as byte */ } DBusBasicValue; # endif diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 492dcad..7872b6e 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -885,6 +885,5 @@ dnsmasqCapsGetVersion(dnsmasqCapsPtr caps) bool dnsmasqCapsGet(dnsmasqCapsPtr caps, dnsmasqCapsFlags flag) { - return caps && virBitmapIsBitSet(caps->flags, flag); } diff --git a/src/util/virfile.c b/src/util/virfile.c index 01ebdb6..19c7890 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2826,7 +2826,6 @@ virFileAccessibleAs(const char *path, uid_t uid ATTRIBUTE_UNUSED, gid_t gid ATTRIBUTE_UNUSED) { - VIR_WARN("Ignoring uid/gid due to WIN32"); return access(path, mode); diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 5d4ad24..80cc32c 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -302,41 +302,41 @@ virNetDevSetMACInternal(const char *ifname, const virMacAddr *macaddr, bool quiet) { - struct ifreq ifr; - struct sockaddr_dl sdl; - char mac[VIR_MAC_STRING_BUFLEN + 1] = ":"; - int s; - int ret = -1; - - if ((s = virNetDevSetupControl(ifname, &ifr)) < 0) - return -1; + struct ifreq ifr; + struct sockaddr_dl sdl; + char mac[VIR_MAC_STRING_BUFLEN + 1] = ":"; + int s; + int ret = -1; - virMacAddrFormat(macaddr, mac + 1); - sdl.sdl_len = sizeof(sdl); - link_addr(mac, &sdl); + if ((s = virNetDevSetupControl(ifname, &ifr)) < 0) + return -1; - memcpy(ifr.ifr_addr.sa_data, sdl.sdl_data, VIR_MAC_BUFLEN); - ifr.ifr_addr.sa_len = VIR_MAC_BUFLEN; + virMacAddrFormat(macaddr, mac + 1); + sdl.sdl_len = sizeof(sdl); + link_addr(mac, &sdl); - if (ioctl(s, SIOCSIFLLADDR, &ifr) < 0) { - if (quiet && - (errno == EADDRNOTAVAIL || errno == EPERM)) - goto cleanup; + memcpy(ifr.ifr_addr.sa_data, sdl.sdl_data, VIR_MAC_BUFLEN); + ifr.ifr_addr.sa_len = VIR_MAC_BUFLEN; - virReportSystemError(errno, - _("Cannot set interface MAC to %s on '%s'"), - mac + 1, ifname); + if (ioctl(s, SIOCSIFLLADDR, &ifr) < 0) { + if (quiet && + (errno == EADDRNOTAVAIL || errno == EPERM)) goto cleanup; - } - ret = 0; + virReportSystemError(errno, + _("Cannot set interface MAC to %s on '%s'"), + mac + 1, ifname); + goto cleanup; + } + + ret = 0; cleanup: - VIR_DEBUG("SIOCSIFLLADDR %s MAC=%s - %s", ifname, mac + 1, - ret < 0 ? "Fail" : "Success"); + VIR_DEBUG("SIOCSIFLLADDR %s MAC=%s - %s", ifname, mac + 1, + ret < 0 ? "Fail" : "Success"); - VIR_FORCE_CLOSE(s); + VIR_FORCE_CLOSE(s); - return ret; + return ret; } @@ -702,7 +702,6 @@ int virNetDevSetOnline(const char *ifname, bool online) { - return virNetDevSetIFFlag(ifname, VIR_IFF_UP, online); } @@ -1138,7 +1137,6 @@ int virNetDevSysfsFile(char **pf_sysfs_device_link, const char *ifname, const char *file) { - if (virAsprintf(pf_sysfs_device_link, SYSFS_NET_DIR "%s/%s", ifname, file) < 0) return -1; return 0; @@ -1148,7 +1146,6 @@ static int virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname, const char *file) { - if (virAsprintf(pf_sysfs_device_link, SYSFS_NET_DIR "%s/device/%s", ifname, file) < 0) return -1; diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 2035b1f..072c0e7 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -83,7 +83,6 @@ virBitmapPtr macvlanIDs = NULL; static int virNetDevMacVLanOnceInit(void) { - if (!macvtapIDs && !(macvtapIDs = virBitmapNew(MACVLAN_MAX_ID + 1))) return -1; @@ -626,11 +625,11 @@ virNetDevMacVLanVPortProfileCallback(struct nlmsghdr *hdr, bool *handled, void *opaque) { - struct nla_policy ifla_vf_policy[IFLA_VF_MAX + 1] = { - [IFLA_VF_MAC] = {.minlen = sizeof(struct ifla_vf_mac), - .maxlen = sizeof(struct ifla_vf_mac)}, - [IFLA_VF_VLAN] = {.minlen = sizeof(struct ifla_vf_vlan), - .maxlen = sizeof(struct ifla_vf_vlan)}, + struct nla_policy ifla_vf_policy[IFLA_VF_MAX + 1] = { + [IFLA_VF_MAC] = {.minlen = sizeof(struct ifla_vf_mac), + .maxlen = sizeof(struct ifla_vf_mac)}, + [IFLA_VF_VLAN] = {.minlen = sizeof(struct ifla_vf_vlan), + .maxlen = sizeof(struct ifla_vf_vlan)}, }; struct nla_policy ifla_port_policy[IFLA_PORT_MAX + 1] = { diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c index 3ebf757..215d649 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -451,7 +451,7 @@ int virNetDevVPortProfileMerge3(virNetDevVPortProfilePtr *result, static struct nla_policy ifla_port_policy[IFLA_PORT_MAX + 1] = { - [IFLA_PORT_RESPONSE] = { .type = NLA_U16 }, + [IFLA_PORT_RESPONSE] = { .type = NLA_U16 }, }; static uint32_t diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 6939d0d..927223e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4753,7 +4753,6 @@ virStorageFileReportBrokenChain(int errcode, virStorageSourcePtr src, virStorageSourcePtr parent) { - if (src->drv) { unsigned int access_user = src->drv->uid; unsigned int access_group = src->drv->gid; diff --git a/src/util/virutil.c b/src/util/virutil.c index a908422..47f5bd0 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -940,7 +940,7 @@ char *virGetUserConfigDirectory(void) char *virGetUserCacheDirectory(void) { - return virGetXDGDirectory("XDG_CACHE_HOME", ".cache"); + return virGetXDGDirectory("XDG_CACHE_HOME", ".cache"); } char *virGetUserRuntimeDirectory(void) @@ -1688,7 +1688,6 @@ virGetDeviceID(const char *path ATTRIBUTE_UNUSED, int *maj ATTRIBUTE_UNUSED, int *min ATTRIBUTE_UNUSED) { - return -ENOSYS; } #endif diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 672caa6..7047e54 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -44,7 +44,6 @@ static vboxUniformedAPI gVBoxAPI; static int vboxConnectNumOfStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED) { - /** Currently only one pool supported, the default one * given by ISystemProperties::defaultHardDiskFolder() */ diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index c9520d4..7a79ec2 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -183,7 +183,6 @@ vzGetDriverConnection(void) void vzDestroyDriverConnection(void) { - vzDriverPtr driver; vzConnPtr privconn_list; diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index c6443d9..5ca906e 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4126,7 +4126,6 @@ prlsdkCreateVm(vzDriverPtr driver, virDomainDefPtr def) static int virStorageTranslatePoolLocal(virConnectPtr conn, virStorageSourcePtr src) { - virStoragePoolPtr pool = NULL; virStorageVolPtr vol = NULL; virStorageVolInfo info; diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 96cad99..f7519cb 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -447,7 +447,6 @@ xenapiNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) static char * xenapiConnectGetCapabilities(virConnectPtr conn) { - virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps; if (caps) return virCapabilitiesFormatXML(caps); @@ -1241,7 +1240,6 @@ xenapiDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo, unsigned char *cpumaps, int maplen) { - xen_vm_set *vms = NULL; xen_vm vm = NULL; xen_string_string_map *vcpu_params = NULL; diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index fdca984..d6d56d8 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -1346,7 +1346,6 @@ xenFormatNet(virConnectPtr conn, static int xenFormatPCI(virConfPtr conf, virDomainDefPtr def) { - virConfValuePtr pciVal = NULL; int hasPCI = 0; size_t i; @@ -1911,11 +1910,11 @@ xenFormatVif(virConfPtr conf, virDomainDefPtr def, const char *vif_typename) { - virConfValuePtr netVal = NULL; - size_t i; - int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM; + virConfValuePtr netVal = NULL; + size_t i; + int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM; - if (VIR_ALLOC(netVal) < 0) + if (VIR_ALLOC(netVal) < 0) goto cleanup; netVal->type = VIR_CONF_LIST; netVal->list = NULL; -- 2.17.1

It would be nice not to mix line removals with re-indentation. Jano On Wed, Sep 12, 2018 at 11:58:21AM +0800, Shi Lei wrote:
Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/bhyve/bhyve_command.c | 3 - src/bhyve/bhyve_conf.c | 6 +- src/bhyve/bhyve_driver.c | 33 +++++------ src/bhyve/bhyve_monitor.c | 1 - src/bhyve/bhyve_process.c | 1 - src/conf/cpu_conf.c | 1 - src/conf/domain_capabilities.c | 1 - src/conf/domain_conf.c | 12 +--- src/conf/network_conf.c | 2 - src/cpu/cpu_s390.c | 82 +++++++++++++------------- src/cpu/cpu_x86.c | 1 - src/esx/esx_vi_types.c | 2 +- src/locking/lock_driver_nop.c | 1 - src/network/bridge_driver.c | 1 - src/network/bridge_driver_linux.c | 1 - src/nwfilter/nwfilter_learnipaddr.c | 1 - src/phyp/phyp_driver.c | 1 - src/qemu/qemu_alias.c | 1 - src/qemu/qemu_domain_address.c | 1 - src/qemu/qemu_driver.c | 1 - src/qemu/qemu_monitor.c | 1 - src/qemu/qemu_monitor_json.c | 1 - src/qemu/qemu_process.c | 1 - src/storage/storage_backend_sheepdog.c | 3 - src/storage/storage_driver.c | 1 - src/storage/storage_util.c | 1 - src/test/test_driver.c | 2 - src/util/vircommand.c | 6 +- src/util/virdbuspriv.h | 18 +++--- src/util/virdnsmasq.c | 1 - src/util/virfile.c | 1 - src/util/virnetdev.c | 55 ++++++++--------- src/util/virnetdevmacvlan.c | 11 ++-- src/util/virnetdevvportprofile.c | 2 +- src/util/virstoragefile.c | 1 - src/util/virutil.c | 3 +- src/vbox/vbox_storage.c | 1 - src/vz/vz_driver.c | 1 - src/vz/vz_sdk.c | 1 - src/xenapi/xenapi_driver.c | 2 - src/xenconfig/xen_common.c | 9 ++- 41 files changed, 111 insertions(+), 164 deletions(-)

On 2018-09-12 at 20:02, Ján Tomko wrote:
It would be nice not to mix line removals with re-indentation.
Jano
It would divide into two patches in v2 series. Shi Lei

Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- tests/qemuxml2argvmock.c | 2 +- tests/sexpr2xmltest.c | 30 +++++----- tests/virnetdevmock.c | 1 - tests/virnettlshelpers.c | 18 +++--- tests/virshtest.c | 118 +++++++++++++++++++-------------------- tests/vshtabletest.c | 3 - tests/xml2sexprtest.c | 24 ++++---- 7 files changed, 96 insertions(+), 100 deletions(-) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 4b4a6f7..79152d9 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -66,7 +66,7 @@ virNumaIsAvailable(void) int virNumaGetMaxNode(void) { - return 7; + return 7; } /* We shouldn't need to mock virNumaNodeIsAvailable() and *definitely* not diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index efe6411..4a1a1ed 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -21,37 +21,37 @@ static virDomainXMLOptionPtr xmlopt; static int testCompareFiles(const char *xml, const char *sexpr) { - char *sexprData = NULL; - char *gotxml = NULL; - int ret = -1; - virDomainDefPtr def = NULL; + char *sexprData = NULL; + char *gotxml = NULL; + int ret = -1; + virDomainDefPtr def = NULL; - if (virTestLoadFile(sexpr, &sexprData) < 0) + if (virTestLoadFile(sexpr, &sexprData) < 0) goto fail; - if (!(def = xenParseSxprString(sexprData, + if (!(def = xenParseSxprString(sexprData, NULL, -1, caps, xmlopt))) goto fail; - if (!virDomainDefCheckABIStability(def, def, xmlopt)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto fail; - } + } - if (!(gotxml = virDomainDefFormat(def, caps, 0))) + if (!(gotxml = virDomainDefFormat(def, caps, 0))) goto fail; - if (virTestCompareToFile(gotxml, xml) < 0) + if (virTestCompareToFile(gotxml, xml) < 0) goto fail; - ret = 0; + ret = 0; fail: - VIR_FREE(sexprData); - VIR_FREE(gotxml); - virDomainDefFree(def); + VIR_FREE(sexprData); + VIR_FREE(gotxml); + virDomainDefFree(def); - return ret; + return ret; } struct testInfo { diff --git a/tests/virnetdevmock.c b/tests/virnetdevmock.c index a9967b7..3eb5059 100644 --- a/tests/virnetdevmock.c +++ b/tests/virnetdevmock.c @@ -34,7 +34,6 @@ virNetDevSysfsFile(char **pf_sysfs_device_link, const char *ifname, const char *file) { - if (virAsprintfQuiet(pf_sysfs_device_link, "%s/%s/%s", NET_DEV_TEST_DATA_PREFIX, ifname, file) < 0) { fprintf(stderr, "Out of memory\n"); diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c index 5c94f89..8cb8c3e 100644 --- a/tests/virnettlshelpers.c +++ b/tests/virnettlshelpers.c @@ -126,19 +126,19 @@ static void testTLSDerEncode(ASN1_TYPE src, const char *src_name, gnutls_datum_t * res) { - int size; - char *data = NULL; + int size; + char *data = NULL; - size = 0; - asn1_der_coding(src, src_name, NULL, &size, NULL); + size = 0; + asn1_der_coding(src, src_name, NULL, &size, NULL); - if (VIR_ALLOC_N(data, size) < 0) - abort(); + if (VIR_ALLOC_N(data, size) < 0) + abort(); - asn1_der_coding(src, src_name, data, &size, NULL); + asn1_der_coding(src, src_name, data, &size, NULL); - res->data = (unsigned char *)data; - res->size = size; + res->data = (unsigned char *)data; + res->size = size; } diff --git a/tests/virshtest.c b/tests/virshtest.c index 10cd0d3..5e73ad9 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -44,18 +44,18 @@ static const char *domstate_fc4 = "running\n\n"; static int testFilterLine(char *buffer, const char *toRemove) { - char *start; - char *end; + char *start; + char *end; - if (!(start = strstr(buffer, toRemove))) + if (!(start = strstr(buffer, toRemove))) return -1; - if (!(end = strstr(start+1, "\n"))) { + if (!(end = strstr(start+1, "\n"))) { *start = '\0'; - } else { + } else { memmove(start, end, strlen(end)+1); - } - return 0; + } + return 0; } static int @@ -96,31 +96,31 @@ static char *custom_uri; static int testCompareListDefault(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_DEFAULT, "list", NULL }; - const char *exp = "\ + const char *const argv[] = { VIRSH_DEFAULT, "list", NULL }; + const char *exp = "\ Id Name State \n\ ----------------------\n\ 1 test running \n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit(exp, NULL, argv); } static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "list", NULL }; - const char *exp = "\ + const char *const argv[] = { VIRSH_CUSTOM, "list", NULL }; + const char *exp = "\ Id Name State \n\ ----------------------\n\ 1 fv0 running \n\ 2 fc4 running \n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit(exp, NULL, argv); } static int testCompareNodeinfoDefault(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_DEFAULT, "nodeinfo", NULL }; - const char *exp = "\ + const char *const argv[] = { VIRSH_DEFAULT, "nodeinfo", NULL }; + const char *exp = "\ CPU model: i686\n\ CPU(s): 16\n\ CPU frequency: 1400 MHz\n\ @@ -130,17 +130,17 @@ Thread(s) per core: 2\n\ NUMA cell(s): 2\n\ Memory size: 3145728 KiB\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit(exp, NULL, argv); } static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { - VIRSH_CUSTOM, - "nodeinfo", - NULL - }; - const char *exp = "\ + const char *const argv[] = { + VIRSH_CUSTOM, + "nodeinfo", + NULL + }; + const char *exp = "\ CPU model: i986\n\ CPU(s): 50\n\ CPU frequency: 6000 MHz\n\ @@ -150,91 +150,91 @@ Thread(s) per core: 2\n\ NUMA cell(s): 4\n\ Memory size: 8192000 KiB\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDominfoByID(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "2", NULL }; - const char *exp = dominfo_fc4; - return testCompareOutputLit(exp, "\nCPU time:", argv); + const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "2", NULL }; + const char *exp = dominfo_fc4; + return testCompareOutputLit(exp, "\nCPU time:", argv); } static int testCompareDominfoByUUID(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_UUID, NULL }; - const char *exp = dominfo_fc4; - return testCompareOutputLit(exp, "\nCPU time:", argv); + const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_UUID, NULL }; + const char *exp = dominfo_fc4; + return testCompareOutputLit(exp, "\nCPU time:", argv); } static int testCompareDominfoByName(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc4", NULL }; - const char *exp = dominfo_fc4; - return testCompareOutputLit(exp, "\nCPU time:", argv); + const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc4", NULL }; + const char *exp = dominfo_fc4; + return testCompareOutputLit(exp, "\nCPU time:", argv); } static int testCompareDomuuidByID(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "2", NULL }; - const char *exp = domuuid_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "2", NULL }; + const char *exp = domuuid_fc4; + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDomuuidByName(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "fc4", NULL }; - const char *exp = domuuid_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "fc4", NULL }; + const char *exp = domuuid_fc4; + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDomidByName(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domid", "fc4", NULL }; - const char *exp = domid_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domid", "fc4", NULL }; + const char *exp = domid_fc4; + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDomidByUUID(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_UUID, NULL }; - const char *exp = domid_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_UUID, NULL }; + const char *exp = domid_fc4; + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDomnameByID(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domname", "2", NULL }; - const char *exp = domname_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domname", "2", NULL }; + const char *exp = domname_fc4; + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDomnameByUUID(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_UUID, NULL }; - const char *exp = domname_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_UUID, NULL }; + const char *exp = domname_fc4; + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDomstateByID(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domstate", "2", NULL }; - const char *exp = domstate_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domstate", "2", NULL }; + const char *exp = domstate_fc4; + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDomstateByUUID(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_UUID, NULL }; - const char *exp = domstate_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_UUID, NULL }; + const char *exp = domstate_fc4; + return testCompareOutputLit(exp, NULL, argv); } static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED) { - const char *const argv[] = { VIRSH_CUSTOM, "domstate", "fc4", NULL }; - const char *exp = domstate_fc4; - return testCompareOutputLit(exp, NULL, argv); + const char *const argv[] = { VIRSH_CUSTOM, "domstate", "fc4", NULL }; + const char *exp = domstate_fc4; + return testCompareOutputLit(exp, NULL, argv); } struct testInfo { diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 1138e34..ce415e8 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -116,7 +116,6 @@ testVshTableRowAppend(const void *opaque ATTRIBUTE_UNUSED) static int testUnicode(const void *opaque ATTRIBUTE_UNUSED) { - int ret = 0; char *act = NULL; @@ -149,7 +148,6 @@ testUnicode(const void *opaque ATTRIBUTE_UNUSED) static int testUnicodeArabic(const void *opaque ATTRIBUTE_UNUSED) { - int ret = 0; char *act = NULL; @@ -193,7 +191,6 @@ testUnicodeArabic(const void *opaque ATTRIBUTE_UNUSED) static int testUnicodeZeroWidthChar(const void *opaque ATTRIBUTE_UNUSED) { - int ret = 0; vshTablePtr table = NULL; const char *exp = diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index 3e4d1d1..959a7ea 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -22,32 +22,32 @@ static virDomainXMLOptionPtr xmlopt; static int testCompareFiles(const char *xml, const char *sexpr) { - char *gotsexpr = NULL; - int ret = -1; - virDomainDefPtr def = NULL; + char *gotsexpr = NULL; + int ret = -1; + virDomainDefPtr def = NULL; - if (!(def = virDomainDefParseFile(xml, caps, xmlopt, NULL, + if (!(def = virDomainDefParseFile(xml, caps, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; - if (!virDomainDefCheckABIStability(def, def, xmlopt)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto fail; - } + } - if (!(gotsexpr = xenFormatSxpr(NULL, def))) + if (!(gotsexpr = xenFormatSxpr(NULL, def))) goto fail; - if (virTestCompareToFile(gotsexpr, sexpr) < 0) + if (virTestCompareToFile(gotsexpr, sexpr) < 0) goto fail; - ret = 0; + ret = 0; fail: - VIR_FREE(gotsexpr); - virDomainDefFree(def); + VIR_FREE(gotsexpr); + virDomainDefFree(def); - return ret; + return ret; } struct testInfo { -- 2.17.1

Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- tools/virsh-volume.c | 1 - tools/virt-admin.c | 1 - 2 files changed, 2 deletions(-) diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 9d6ebd2..42d1170 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -520,7 +520,6 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) static xmlChar * virshMakeCloneXML(const char *origxml, const char *newname) { - xmlDocPtr doc = NULL; xmlXPathContextPtr ctxt = NULL; xmlXPathObjectPtr obj = NULL; diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 107a1d8..63822bc 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -82,7 +82,6 @@ vshAdmClientTransportToString(int transport) static int vshAdmGetTimeStr(vshControl *ctl, time_t then, char **result) { - char *tmp = NULL; struct tm timeinfo; -- 2.17.1

This commit only fixes empty lines, why mention incorrect indentation? Jano On Wed, Sep 12, 2018 at 11:58:23AM +0800, Shi Lei wrote:
Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- tools/virsh-volume.c | 1 - tools/virt-admin.c | 1 - 2 files changed, 2 deletions(-)

On 2018-09-12 at 19:59, Ján Tomko wrote:
This commit only fixes empty lines, why mention incorrect indentation?
Jano
Oh, sorry. I would change this commit message. Shi Lei
On Wed, Sep 12, 2018 at 11:58:23AM +0800, Shi Lei wrote:
Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- tools/virsh-volume.c | 1 - tools/virt-admin.c | 1 - 2 files changed, 2 deletions(-)
participants (2)
-
Ján Tomko
-
Shi Lei