[libvirt] [PATCH 00/22] syntax-check: Check misaligned stuff and fix them (batch II)

This series is batch(II) and it continues to fix misaligned arguments and misaligned conditions in src directory. The batch I: https://www.redhat.com/archives/libvir-list/2018-September/msg00888.html In addition to fix misaligned stuff, this series includes several other jobs: ========================================== 1. Relax the checking-rule for misaligned. ========================================== In addition to the check-rule in batch I, a new code style is okay: Linefeed can be put behind the open-parenthesis of the function, the position of argument should be: 1) pos % 4 == 0 2) pos > start_of_function_name(includes func's parent_pointer) 3) pos is the first place which matches 1) and 2) E.g. [indent]if (virLongLongLongFunctionName( [4-spaces-align]LongLongLongFirstName, [4-spaces-align]LongLongLongSecondName) < 0) or [indent]ret = pointer->virFunctionName( [4-spaces-align]LongLongLongFirstName, [4-spaces-align]LongLongLongSecondName); ==================================================== 2. Add indicator to help correcting misaligned stuff. ==================================================== The [patch 21/22] definitely indicates the correct position. =========================================== 3. Improve the speed of check-spacing.pl . =========================================== The [patch 22/22] uses global var, rather than passing arguments to subroutine. It can be a bit faster. The benchmark for check-spacing.pl on my PC: (before batch I ) 1.6s (before batch II ) 3.3s (apply this patch) 2.7s ==================================================== # Remaining work after this batch. (for src directory) ==================================================== DIR Misaligned(lines) esx 334 qemu 227 hyperv 104 lxc 60 conf 76 libxl 69 vbox 65 test 60 security 62 Plan to fix them in two or three weeks. Shi Lei (22): access: Fix misaligned arguments admin: Fix misaligned arguments bhyve: Fix misaligned arguments and misaligned conditions cpu: Fix misaligned arguments interface: Fix misaligned arguments locking: Fix misaligned arguments network: Fix misaligned arguments src:libvirt*.c: Fix misaligned arguments nwfilter: Fix misaligned arguments and misaligned conditions phyp: Fix misaligned arguments remote: Fix misaligned arguments rpc: Fix misaligned arguments storage: Fix misaligned arguments and misaligned conditions uml: Fix misaligned arguments vmware: Fix misaligned arguments and misaligned conditions vmx: Fix misaligned arguments vz: Fix misaligned arguments and misaligned conditions xenapi: Fix misaligned arguments xenconfig: Fix misaligned arguments and misaligned conditions build-aux:check-spacing: Relax the check-rule for misaligned stuff build-aux:check-spacing: Add indicator to help correcting misaligned stuff build-aux:check-spacing: Remove arguments of subroutines for speed build-aux/check-spacing.pl | 247 +++++++++++---------- src/access/viraccessdriverpolkit.c | 6 +- src/admin/admin_server.c | 2 +- src/admin/admin_server_dispatch.c | 4 +- src/bhyve/bhyve_capabilities.c | 7 +- src/bhyve/bhyve_command.c | 6 +- src/bhyve/bhyve_driver.c | 10 +- src/bhyve/bhyve_monitor.c | 4 +- src/bhyve/bhyve_parse_command.c | 16 +- src/bhyve/bhyve_process.c | 6 +- src/cpu/cpu_ppc64.c | 4 +- src/cpu/cpu_x86.c | 16 +- src/interface/interface_backend_udev.c | 102 +++++---- src/libvirt-domain.c | 14 +- src/libvirt-host.c | 4 +- src/libvirt-lxc.c | 5 +- src/libvirt-network.c | 2 +- src/libvirt-nodedev.c | 4 +- src/libvirt-storage.c | 13 +- src/libvirt.c | 4 +- src/locking/lock_manager.c | 4 +- src/network/bridge_driver.c | 25 +-- src/nwfilter/nwfilter_dhcpsnoop.c | 10 +- src/nwfilter/nwfilter_driver.c | 8 +- src/nwfilter/nwfilter_ebiptables_driver.c | 18 +- src/nwfilter/nwfilter_learnipaddr.c | 36 ++- src/phyp/phyp_driver.c | 20 +- src/remote/remote_daemon.c | 2 +- src/remote/remote_daemon_dispatch.c | 16 +- src/remote/remote_driver.c | 31 +-- src/rpc/virnetclient.c | 40 ++-- src/rpc/virnetlibsshsession.c | 2 +- src/rpc/virnetservermdns.c | 4 +- src/rpc/virnetsocket.c | 23 +- src/rpc/virnetsshsession.c | 2 +- src/storage/storage_backend_disk.c | 7 +- src/storage/storage_backend_gluster.c | 2 +- src/storage/storage_backend_iscsi_direct.c | 2 +- src/storage/storage_backend_rbd.c | 14 +- src/storage/storage_driver.c | 6 +- src/storage/storage_util.c | 16 +- src/uml/uml_driver.c | 50 ++--- src/vmware/vmware_conf.c | 2 +- src/vmware/vmware_driver.c | 10 +- src/vmx/vmx.c | 23 +- src/vz/vz_driver.c | 14 +- src/vz/vz_sdk.c | 26 ++- src/vz/vz_utils.c | 2 +- src/xenapi/xenapi_utils.c | 12 +- src/xenconfig/xen_common.c | 21 +- src/xenconfig/xen_xl.c | 23 +- src/xenconfig/xen_xm.c | 8 +- 52 files changed, 488 insertions(+), 467 deletions(-) -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/access/viraccessdriverpolkit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/access/viraccessdriverpolkit.c b/src/access/viraccessdriverpolkit.c index 6954d74..46d7835 100644 --- a/src/access/viraccessdriverpolkit.c +++ b/src/access/viraccessdriverpolkit.c @@ -367,9 +367,9 @@ virAccessDriverPolkitCheckSecret(virAccessManagerPtr manager, }; return virAccessDriverPolkitCheck(manager, - "secret", - virAccessPermSecretTypeToString(perm), - attrs); + "secret", + virAccessPermSecretTypeToString(perm), + attrs); } break; } } -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/admin/admin_server.c | 2 +- src/admin/admin_server_dispatch.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/admin/admin_server.c b/src/admin/admin_server.c index f2c1a8f..f1e9667 100644 --- a/src/admin/admin_server.c +++ b/src/admin/admin_server.c @@ -291,7 +291,7 @@ adminClientGetInfo(virNetServerClientPtr client, if (virIdentityGetSELinuxContext(identity, &attr) < 0 || (attr && virTypedParamsAddString(&tmpparams, nparams, &maxparams, - VIR_CLIENT_INFO_SELINUX_CONTEXT, attr) < 0)) + VIR_CLIENT_INFO_SELINUX_CONTEXT, attr) < 0)) goto cleanup; *params = tmpparams; diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dispatch.c index b78ff90..83e5953 100644 --- a/src/admin/admin_server_dispatch.c +++ b/src/admin/admin_server_dispatch.c @@ -396,8 +396,8 @@ adminDispatchServerSetClientLimits(virNetServerPtr server ATTRIBUTE_UNUSED, } if (virTypedParamsDeserialize((virTypedParameterRemotePtr) args->params.params_val, - args->params.params_len, - ADMIN_SERVER_CLIENT_LIMITS_MAX, ¶ms, &nparams) < 0) + args->params.params_len, + ADMIN_SERVER_CLIENT_LIMITS_MAX, ¶ms, &nparams) < 0) goto cleanup; if (adminServerSetClientLimits(srv, params, nparams, args->flags) < 0) -- 2.17.1

This patch fixes misaligned arguments and misaligned conditions. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/bhyve/bhyve_capabilities.c | 7 +++---- src/bhyve/bhyve_command.c | 6 +++--- src/bhyve/bhyve_driver.c | 10 +++++----- src/bhyve/bhyve_monitor.c | 4 ++-- src/bhyve/bhyve_parse_command.c | 16 ++++++++-------- src/bhyve/bhyve_process.c | 6 +++--- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 6feaded..1984c85 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -139,12 +139,11 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn, if (virDirOpenIfExists(&dir, firmware_dir) > 0) { while ((virDirRead(dir, &entry, firmware_dir)) > 0) { if (VIR_RESIZE_N(firmwares->values, - firmwares_alloc, firmwares->nvalues, 1) < 0) + firmwares_alloc, firmwares->nvalues, 1) < 0) goto cleanup; - if (virAsprintf( - &firmwares->values[firmwares->nvalues], - "%s/%s", firmware_dir, entry->d_name) < 0) + if (virAsprintf(&firmwares->values[firmwares->nvalues], + "%s/%s", firmware_dir, entry->d_name) < 0) goto cleanup; firmwares->nvalues++; diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 6149c93..7f2d2f5 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -293,8 +293,8 @@ bhyveBuildUSBControllerArgStr(const virDomainDef *def, static int bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, - virDomainDiskDefPtr disk, - virCommandPtr cmd) + virDomainDiskDefPtr disk, + virCommandPtr cmd) { const char *disk_source; @@ -516,7 +516,7 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Installed bhyve binary does not support " - "UTC clock")); + "UTC clock")); goto error; } break; diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 4d4f85f..06c7012 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -727,12 +727,12 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_LPC_BOOTROM) == 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Installed bhyve binary does not support " - "bootrom")); + "bootrom")); goto cleanup; } } else { if (!(loadcmd = virBhyveProcessBuildLoadCmd(conn, def, "<device.map>", - NULL))) + NULL))) goto cleanup; virBufferAdd(&buf, virCommandToString(loadcmd), -1); @@ -1107,9 +1107,9 @@ bhyveDomainSetMetadata(virDomainPtr dom, static char * bhyveDomainGetMetadata(virDomainPtr dom, - int type, - const char *uri, - unsigned int flags) + int type, + const char *uri, + unsigned int flags) { virDomainObjPtr vm; char *ret = NULL; diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index 4d5262c..ba1879d 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -79,8 +79,8 @@ bhyveMonitorIO(int watch, int kq, int events ATTRIBUTE_UNUSED, void *opaque) if (kev.filter == EVFILT_PROC && (kev.fflags & NOTE_EXIT) != 0) { if ((pid_t)kev.ident != vm->pid) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("event from unexpected proc %ju!=%ju"), - (uintmax_t)vm->pid, (uintmax_t)kev.ident); + _("event from unexpected proc %ju!=%ju"), + (uintmax_t)vm->pid, (uintmax_t)kev.ident); return; } diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 14137d1..5424d97 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -63,7 +63,7 @@ bhyveParseCommandLineUnescape(const char *command) /* Iterate over characters in the command, skipping "\\\n", "\\\r" as well * as "\\\r\n". */ for (curr_src = (char*) command, curr_dst = unescaped; *curr_src != '\0'; - curr_src++, curr_dst++) { + curr_src++, curr_dst++) { if (*curr_src == '\\') { switch (*(curr_src + 1)) { case '\n': /* \LF */ @@ -122,10 +122,10 @@ bhyveParseMemsize(const char *arg, size_t *ret_memsize) */ static int bhyveCommandLineToArgv(const char *nativeConfig, - int *loader_argc, - char ***loader_argv, - int *bhyve_argc, - char ***bhyve_argv) + int *loader_argc, + char ***loader_argv, + int *bhyve_argc, + char ***bhyve_argv) { const char *curr = NULL; char *nativeConfig_unescaped = NULL; @@ -663,7 +663,7 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def, goto error; while ((c = _getopt_internal_r(argc, argv, optstr, - NULL, NULL, 0, parser, 0)) != -1) { + NULL, NULL, 0, parser, 0)) != -1) { switch (c) { case 'A': def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_TRISTATE_SWITCH_ON; @@ -700,7 +700,7 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def, } if (def->mem.cur_balloon != 0 && def->mem.cur_balloon != memory) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("Failed to parse memory: size mismatch")); + _("Failed to parse memory: size mismatch")); goto error; } def->mem.cur_balloon = memory; @@ -778,7 +778,7 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def, goto error; while ((c = _getopt_internal_r(argc, argv, optstr, - NULL, NULL, 0, parser, 0)) != -1) { + NULL, NULL, 0, parser, 0)) != -1) { switch (c) { case 'd': arguments |= 1; diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 4dab6e5..089f4ae 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -77,9 +77,9 @@ bhyveNetCleanup(virDomainObjPtr vm) if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) { if (net->ifname) { - ignore_value(virNetDevBridgeRemovePort( - virDomainNetGetActualBridgeName(net), - net->ifname)); + const char *brname = virDomainNetGetActualBridgeName(net); + ignore_value(virNetDevBridgeRemovePort(brname, + net->ifname)); ignore_value(virNetDevTapDelete(net->ifname, NULL)); } } -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/cpu/cpu_ppc64.c | 4 ++-- src/cpu/cpu_x86.c | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index 858f40e..96f9df1 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -488,7 +488,7 @@ ppc64Compute(virCPUDefPtr host, if (message && virAsprintf(message, _("host CPU vendor does not match required " - "CPU vendor %s"), + "CPU vendor %s"), cpu->vendor) < 0) goto cleanup; @@ -543,7 +543,7 @@ ppc64Compute(virCPUDefPtr host, if (message && virAsprintf(message, _("host CPU model does not match required " - "CPU model %s"), + "CPU model %s"), guest_model->name) < 0) goto cleanup; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 69a0c8d..e978cf0 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2040,12 +2040,8 @@ cpuidCall(virCPUx86CPUID *cpuid) asm("xor %%ebx, %%ebx;" /* clear the other registers as some cpuid */ "xor %%edx, %%edx;" /* functions may use them as additional arguments */ "cpuid;" - : "=a" (cpuid->eax), - "=b" (cpuid->ebx), - "=c" (cpuid->ecx), - "=d" (cpuid->edx) - : "a" (cpuid->eax_in), - "c" (cpuid->ecx_in)); + : "=a" (cpuid->eax), "=b" (cpuid->ebx), "=c" (cpuid->ecx), "=d" (cpuid->edx) + : "a" (cpuid->eax_in), "c" (cpuid->ecx_in)); # else /* we need to avoid direct use of ebx for CPUID output as it is used * for global offset table on i386 with -fPIC @@ -2056,12 +2052,8 @@ cpuidCall(virCPUx86CPUID *cpuid) "cpuid;" "mov %%ebx, %1;" "pop %%ebx;" - : "=a" (cpuid->eax), - "=r" (cpuid->ebx), - "=c" (cpuid->ecx), - "=d" (cpuid->edx) - : "a" (cpuid->eax_in), - "c" (cpuid->ecx_in) + : "=a" (cpuid->eax), "=r" (cpuid->ebx), "=c" (cpuid->ecx), "=d" (cpuid->edx) + : "a" (cpuid->eax_in), "c" (cpuid->ecx_in) : "cc"); # endif } -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/interface/interface_backend_udev.c | 102 ++++++++++++++----------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c index 1373356..64ed2e3 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -602,13 +602,14 @@ udevGetIfaceDefBond(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bonding/downdelay"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bonding/downdelay' for '%s'"), name); + _("Could not retrieve 'bonding/downdelay' for '%s'"), + name); goto error; } if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse 'bonding/downdelay' '%s' for '%s'"), - tmp_str, name); + _("Could not parse 'bonding/downdelay' '%s' for '%s'"), + tmp_str, name); goto error; } ifacedef->data.bond.downdelay = tmp_int; @@ -616,13 +617,14 @@ udevGetIfaceDefBond(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bonding/updelay"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bonding/updelay' for '%s'"), name); + _("Could not retrieve 'bonding/updelay' for '%s'"), + name); goto error; } if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse 'bonding/updelay' '%s' for '%s'"), - tmp_str, name); + _("Could not parse 'bonding/updelay' '%s' for '%s'"), + tmp_str, name); goto error; } ifacedef->data.bond.updelay = tmp_int; @@ -630,13 +632,14 @@ udevGetIfaceDefBond(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bonding/miimon"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bonding/miimon' for '%s'"), name); + _("Could not retrieve 'bonding/miimon' for '%s'"), + name); goto error; } if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse 'bonding/miimon' '%s' for '%s'"), - tmp_str, name); + _("Could not parse 'bonding/miimon' '%s' for '%s'"), + tmp_str, name); goto error; } ifacedef->data.bond.frequency = tmp_int; @@ -644,13 +647,14 @@ udevGetIfaceDefBond(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bonding/arp_interval"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bonding/arp_interval' for '%s'"), name); + _("Could not retrieve 'bonding/arp_interval' for '%s'"), + name); goto error; } if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse 'bonding/arp_interval' '%s' for '%s'"), - tmp_str, name); + _("Could not parse 'bonding/arp_interval' '%s' for '%s'"), + tmp_str, name); goto error; } ifacedef->data.bond.interval = tmp_int; @@ -663,25 +667,25 @@ udevGetIfaceDefBond(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bonding/mode"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bonding/mode' for '%s'"), name); + _("Could not retrieve 'bonding/mode' for '%s'"), name); goto error; } tmp_str = strchr(tmp_str, ' '); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid format for 'bonding/mode' for '%s'"), name); + _("Invalid format for 'bonding/mode' for '%s'"), name); goto error; } if (strlen(tmp_str) < 2) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find correct value in 'bonding/mode' for '%s'"), - name); + _("Unable to find correct value in 'bonding/mode' for '%s'"), + name); goto error; } if (virStrToLong_i(tmp_str + 1, NULL, 10, &tmp_int) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse 'bonding/mode' '%s' for '%s'"), - tmp_str, name); + _("Could not parse 'bonding/mode' '%s' for '%s'"), + tmp_str, name); goto error; } ifacedef->data.bond.mode = tmp_int + 1; @@ -693,25 +697,27 @@ udevGetIfaceDefBond(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bonding/arp_validate"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bonding/arp_validate' for '%s'"), name); + _("Could not retrieve 'bonding/arp_validate' for '%s'"), + name); goto error; } tmp_str = strchr(tmp_str, ' '); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid format for 'bonding/arp_validate' for '%s'"), name); + _("Invalid format for 'bonding/arp_validate' for '%s'"), + name); goto error; } if (strlen(tmp_str) < 2) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find correct value in 'bonding/arp_validate' " - "for '%s'"), name); + _("Unable to find correct value in 'bonding/arp_validate' " + "for '%s'"), name); goto error; } if (virStrToLong_i(tmp_str + 1, NULL, 10, &tmp_int) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse 'bonding/arp_validate' '%s' for '%s'"), - tmp_str, name); + _("Could not parse 'bonding/arp_validate' '%s' for '%s'"), + tmp_str, name); goto error; } ifacedef->data.bond.validate = tmp_int; @@ -720,13 +726,14 @@ udevGetIfaceDefBond(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bonding/use_carrier"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bonding/use_carrier' for '%s'"), name); + _("Could not retrieve 'bonding/use_carrier' for '%s'"), + name); goto error; } if (virStrToLong_i(tmp_str, NULL, 10, &tmp_int) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse 'bonding/use_carrier' '%s' for '%s'"), - tmp_str, name); + _("Could not parse 'bonding/use_carrier' '%s' for '%s'"), + tmp_str, name); goto error; } ifacedef->data.bond.carrier = tmp_int + 1; @@ -745,7 +752,8 @@ udevGetIfaceDefBond(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bonding/arp_ip_target"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bonding/arp_ip_target' for '%s'"), name); + _("Could not retrieve 'bonding/arp_ip_target' for '%s'"), + name); goto error; } if (VIR_STRDUP(ifacedef->data.bond.target, tmp_str) < 0) @@ -754,11 +762,11 @@ udevGetIfaceDefBond(struct udev *udev, /* Slaves of the bond */ /* Get each slave in the bond */ slave_count = scandir(udev_device_get_syspath(dev), &slave_list, - udevBondScanDirFilter, alphasort); + udevBondScanDirFilter, alphasort); if (slave_count < 0) { virReportSystemError(errno, - _("Could not get slaves of bond '%s'"), name); + _("Could not get slaves of bond '%s'"), name); goto error; } @@ -785,8 +793,9 @@ udevGetIfaceDefBond(struct udev *udev, udevGetIfaceDef(udev, tmp_str); if (!ifacedef->data.bond.itf[i]) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get interface information for '%s', which is " - "a enslaved in bond '%s'"), slave_list[i]->d_name, name); + _("Could not get interface information for '%s'," + " which is a enslaved in bond '%s'"), + slave_list[i]->d_name, name); goto error; } VIR_FREE(slave_list[i]); @@ -826,7 +835,8 @@ udevGetIfaceDefBridge(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bridge/forward_delay"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bridge/forward_delay' for '%s'"), name); + _("Could not retrieve 'bridge/forward_delay' for '%s'"), + name); goto error; } @@ -837,14 +847,15 @@ udevGetIfaceDefBridge(struct udev *udev, tmp_str = udev_device_get_sysattr_value(dev, "bridge/stp_state"); if (!tmp_str) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not retrieve 'bridge/stp_state' for '%s'"), name); + _("Could not retrieve 'bridge/stp_state' for '%s'"), + name); goto error; } if (virStrToLong_i(tmp_str, NULL, 10, &stp) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse 'bridge/stp_state' '%s' for '%s'"), - tmp_str, name); + _("Could not parse 'bridge/stp_state' '%s' for '%s'"), + tmp_str, name); goto error; } @@ -856,27 +867,27 @@ udevGetIfaceDefBridge(struct udev *udev, break; default: virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid STP state value %d received for '%s'. Must be " - "-1, 0, or 1."), stp, name); + _("Invalid STP state value %d received for '%s'." + " Must be -1, 0, or 1."), stp, name); goto error; } /* Members of the bridge */ if (virAsprintf(&member_path, "%s/%s", - udev_device_get_syspath(dev), "brif") < 0) + udev_device_get_syspath(dev), "brif") < 0) goto error; /* Get each member of the bridge */ member_count = scandir(member_path, &member_list, - udevBridgeScanDirFilter, alphasort); + udevBridgeScanDirFilter, alphasort); /* Don't need the path anymore */ VIR_FREE(member_path); if (member_count < 0) { virReportSystemError(errno, - _("Could not get members of bridge '%s'"), - name); + _("Could not get members of bridge '%s'"), + name); goto error; } @@ -891,8 +902,9 @@ udevGetIfaceDefBridge(struct udev *udev, udevGetIfaceDef(udev, member_list[i]->d_name); if (!ifacedef->data.bridge.itf[i]) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get interface information for '%s', which is " - "a member of bridge '%s'"), member_list[i]->d_name, name); + _("Could not get interface information for '%s', " + "which is a member of bridge '%s'"), + member_list[i]->d_name, name); goto error; } VIR_FREE(member_list[i]); @@ -1018,7 +1030,7 @@ udevGetIfaceDef(struct udev *udev, const char *name) mtu_str = udev_device_get_sysattr_value(dev, "mtu"); if (virStrToLong_ui(mtu_str, NULL, 10, &mtu) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not parse MTU value '%s'"), mtu_str); + _("Could not parse MTU value '%s'"), mtu_str); goto error; } ifacedef->mtu = mtu; -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/locking/lock_manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c index 9067f5a..8872334 100644 --- a/src/locking/lock_manager.c +++ b/src/locking/lock_manager.c @@ -44,8 +44,8 @@ VIR_LOG_INIT("locking.lock_manager"); #define CHECK_DRIVER(field, errret) \ if (!driver->field) { \ virReportError(VIR_ERR_INTERNAL_ERROR, \ - _("Missing '%s' field in lock manager driver"), \ - #field); \ + _("Missing '%s' field in lock manager driver"), \ + #field); \ return errret; \ } -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/network/bridge_driver.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 4bbc4f5..fbbc024 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3478,9 +3478,9 @@ networkValidate(virNetworkDriverStatePtr driver, if (ipdef->nranges || ipdef->nhosts) { if (ipv4def) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Multiple IPv4 dhcp sections found -- " - "dhcp is supported only for a " - "single IPv4 address on each network")); + _("Multiple IPv4 dhcp sections found -- " + "dhcp is supported only for a " + "single IPv4 address on each network")); return -1; } else { ipv4def = true; @@ -3491,9 +3491,9 @@ networkValidate(virNetworkDriverStatePtr driver, if (ipdef->nranges || ipdef->nhosts) { if (ipv6def) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Multiple IPv6 dhcp sections found -- " - "dhcp is supported only for a " - "single IPv6 address on each network")); + _("Multiple IPv6 dhcp sections found -- " + "dhcp is supported only for a " + "single IPv6 address on each network")); return -1; } else { ipv6def = true; @@ -4321,7 +4321,7 @@ networkGetDHCPLeases(virNetworkPtr net, break; } if (!ipv6 && VIR_SOCKET_ADDR_IS_FAMILY(&ipdef_tmp->address, - AF_INET)) { + AF_INET)) { lease->prefix = virSocketAddrGetIPPrefix(&ipdef_tmp->address, &ipdef_tmp->netmask, ipdef_tmp->prefix); @@ -5740,12 +5740,11 @@ networkRegister(void) if (virRegisterStateDriver(&networkStateDriver) < 0) return -1; - virDomainNetSetDeviceImpl( - networkAllocateActualDevice, - networkNotifyActualDevice, - networkReleaseActualDevice, - networkBandwidthChangeAllowed, - networkBandwidthUpdate); + virDomainNetSetDeviceImpl(networkAllocateActualDevice, + networkNotifyActualDevice, + networkReleaseActualDevice, + networkBandwidthChangeAllowed, + networkBandwidthUpdate); return 0; } -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/libvirt-domain.c | 14 +++++++------- src/libvirt-host.c | 4 ++-- src/libvirt-lxc.c | 5 ++--- src/libvirt-network.c | 2 +- src/libvirt-nodedev.c | 4 ++-- src/libvirt-storage.c | 13 ++++++------- src/libvirt.c | 4 ++-- 7 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7690339..23f4889 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -3626,7 +3626,7 @@ virDomainMigrate(virDomainPtr domain, } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_V2) && VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V2)) { + VIR_DRV_FEATURE_MIGRATION_V2)) { VIR_DEBUG("Using migration protocol 2"); ddomain = virDomainMigrateVersion2(domain, dconn, flags, dname, uri, bandwidth); @@ -3778,7 +3778,7 @@ virDomainMigrate2(virDomainPtr domain, } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_V2) && VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V2)) { + VIR_DRV_FEATURE_MIGRATION_V2)) { VIR_DEBUG("Using migration protocol 2"); if (dxml) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", @@ -3967,7 +3967,7 @@ virDomainMigrate3(virDomainPtr domain, } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_V2) && VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, - VIR_DRV_FEATURE_MIGRATION_V2)) { + VIR_DRV_FEATURE_MIGRATION_V2)) { VIR_DEBUG("Using migration protocol 2"); if (dxml) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", @@ -11051,8 +11051,8 @@ virDomainFSFreeze(virDomainPtr dom, virCheckNullArgGoto(mountpoints, error); if (dom->conn->driver->domainFSFreeze) { - int ret = dom->conn->driver->domainFSFreeze( - dom, mountpoints, nmountpoints, flags); + int ret = dom->conn->driver->domainFSFreeze(dom, mountpoints, + nmountpoints, flags); if (ret < 0) goto error; return ret; @@ -11096,8 +11096,8 @@ virDomainFSThaw(virDomainPtr dom, virCheckNullArgGoto(mountpoints, error); if (dom->conn->driver->domainFSThaw) { - int ret = dom->conn->driver->domainFSThaw( - dom, mountpoints, nmountpoints, flags); + int ret = dom->conn->driver->domainFSThaw(dom, mountpoints, + nmountpoints, flags); if (ret < 0) goto error; return ret; diff --git a/src/libvirt-host.c b/src/libvirt-host.c index e20d6ee..a044924 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -784,7 +784,7 @@ virNodeSetMemoryParameters(virConnectPtr conn, if (conn->driver->nodeSetMemoryParameters) { int ret; ret = conn->driver->nodeSetMemoryParameters(conn, params, - nparams, flags); + nparams, flags); if (ret < 0) goto error; return ret; @@ -857,7 +857,7 @@ virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, int startCell, int maxCells) { VIR_DEBUG("conn=%p, freeMems=%p, startCell=%d, maxCells=%d", - conn, freeMems, startCell, maxCells); + conn, freeMems, startCell, maxCells); virResetLastError(); diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index 9bf0174..380d008 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -235,9 +235,8 @@ virDomainLxcEnterSecurityLabel(virSecurityModelPtr model, } if (setexeccon(label->label) < 0) { - virReportSystemError(errno, - _("Cannot set context %s"), - label->label); + virReportSystemError(errno, _("Cannot set context %s"), + label->label); goto error; } #else diff --git a/src/libvirt-network.c b/src/libvirt-network.c index 9f9e0dd..42e2b3b 100644 --- a/src/libvirt-network.c +++ b/src/libvirt-network.c @@ -1200,7 +1200,7 @@ virNetworkGetDHCPLeases(virNetworkPtr network, { virConnectPtr conn; VIR_DEBUG("network=%p, mac='%s' leases=%p, flags=0x%x", - network, NULLSTR(mac), leases, flags); + network, NULLSTR(mac), leases, flags); virResetLastError(); diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c index 10050b1..5a27a10 100644 --- a/src/libvirt-nodedev.c +++ b/src/libvirt-nodedev.c @@ -258,7 +258,7 @@ virNodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, conn->nodeDeviceDriver->nodeDeviceLookupSCSIHostByWWN) { virNodeDevicePtr ret; ret = conn->nodeDeviceDriver->nodeDeviceLookupSCSIHostByWWN(conn, wwnn, - wwpn, flags); + wwpn, flags); if (!ret) goto error; return ret; @@ -410,7 +410,7 @@ virNodeDeviceListCaps(virNodeDevicePtr dev, int maxnames) { VIR_DEBUG("dev=%p, conn=%p, names=%p, maxnames=%d", - dev, dev ? dev->conn : NULL, names, maxnames); + dev, dev ? dev->conn : NULL, names, maxnames); virResetLastError(); diff --git a/src/libvirt-storage.c b/src/libvirt-storage.c index 2ea3e94..e65eee5 100644 --- a/src/libvirt-storage.c +++ b/src/libvirt-storage.c @@ -1561,8 +1561,10 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool, if (pool->conn->storageDriver && pool->conn->storageDriver->storageVolCreateXMLFrom) { virStorageVolPtr ret; - ret = pool->conn->storageDriver->storageVolCreateXMLFrom(pool, xmlDesc, - clonevol, flags); + ret = pool->conn->storageDriver->storageVolCreateXMLFrom(pool, + xmlDesc, + clonevol, + flags); if (!ret) goto error; return ret; @@ -1709,11 +1711,8 @@ virStorageVolUpload(virStorageVolPtr vol, if (vol->conn->storageDriver && vol->conn->storageDriver->storageVolUpload) { int ret; - ret = vol->conn->storageDriver->storageVolUpload(vol, - stream, - offset, - length, - flags); + ret = vol->conn->storageDriver->storageVolUpload(vol, stream, offset, + length, flags); if (ret < 0) goto error; return ret; diff --git a/src/libvirt.c b/src/libvirt.c index 0a738ae..93d433f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -581,7 +581,7 @@ virRegisterConnectDriver(virConnectDriverPtr driver, } VIR_DEBUG("registering %s as driver %d", - driver->hypervisorDriver->name, virConnectDriverTabCount); + driver->hypervisorDriver->name, virConnectDriverTabCount); if (setSharedDrivers) { if (driver->interfaceDriver == NULL) @@ -1046,7 +1046,7 @@ virConnectOpenInternal(const char *name, i, virConnectDriverTab[i]->hypervisorDriver->name, res == VIR_DRV_OPEN_SUCCESS ? "SUCCESS" : (res == VIR_DRV_OPEN_DECLINED ? "DECLINED" : - (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); + (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status"))); if (res == VIR_DRV_OPEN_SUCCESS) { break; -- 2.17.1

This patch fixes misaligned arguments and misaligned conditions. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/nwfilter/nwfilter_dhcpsnoop.c | 10 +++---- src/nwfilter/nwfilter_driver.c | 8 ++--- src/nwfilter/nwfilter_ebiptables_driver.c | 18 +++++------- src/nwfilter/nwfilter_learnipaddr.c | 36 +++++++++-------------- 4 files changed, 31 insertions(+), 41 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index e40f649..535c88d 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1537,12 +1537,12 @@ virNWFilterDHCPSnoopThread(void *req0) } if (virNWFilterSnoopDHCPDecodeJobSubmit(worker, packet, - hdr->caplen, - pcapConf[i].dir, - &pcapConf[i].qCtr) < 0) { + hdr->caplen, + pcapConf[i].dir, + &pcapConf[i].qCtr) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Job submission failed on " - "interface '%s'"), req->binding->portdevname); + _("Job submission failed on interface '%s'"), + req->binding->portdevname); error = true; break; } diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 1ee5162..8737769 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -228,7 +228,7 @@ nwfilterStateInitialize(bool privileged, nwfilterDriverInstallDBusMatches(sysbus) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("DBus matches could not be installed. " - "Disabling nwfilter driver")); + "Disabling nwfilter driver")); /* * unfortunately this is fatal since virNWFilterTechDriversInit * may have caused the ebiptables driver to use the firewall tool @@ -495,7 +495,7 @@ nwfilterConnectNumOfNWFilters(virConnectPtr conn) return -1; return virNWFilterObjListNumOfNWFilters(driver->nwfilters, conn, - virConnectNumOfNWFiltersCheckACL); + virConnectNumOfNWFiltersCheckACL); } @@ -511,8 +511,8 @@ nwfilterConnectListNWFilters(virConnectPtr conn, nwfilterDriverLock(); nnames = virNWFilterObjListGetNames(driver->nwfilters, conn, - virConnectListNWFiltersCheckACL, - names, maxnames); + virConnectListNWFiltersCheckACL, + names, maxnames); nwfilterDriverUnlock(); return nnames; } diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c index 5be1c9b..7ace424 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -1703,7 +1703,7 @@ iptablesCreateRuleInstance(virFirewallPtr fw, const char *matchState; if (!(rule->flags & RULE_FLAG_NO_STATEMATCH) && - (rule->flags & IPTABLES_STATE_FLAGS)) { + (rule->flags & IPTABLES_STATE_FLAGS)) { return iptablesCreateRuleInstanceStateCtrl(fw, layer, rule, @@ -1833,8 +1833,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, virBuffer buf = VIR_BUFFER_INITIALIZER; if (STREQ(chainSuffix, - virNWFilterChainSuffixTypeToString( - VIR_NWFILTER_CHAINSUFFIX_ROOT))) + virNWFilterChainSuffixTypeToString(VIR_NWFILTER_CHAINSUFFIX_ROOT))) PRINT_ROOT_CHAIN(chain, chainPrefix, ifname); else PRINT_CHAIN(chain, chainPrefix, ifname, @@ -1927,7 +1926,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, _("STP filtering in %s direction with " "source MAC address set is not supported"), virNWFilterRuleDirectionTypeToString( - VIR_NWFILTER_RULE_DIRECTION_INOUT)); + VIR_NWFILTER_RULE_DIRECTION_INOUT)); return -1; } @@ -2441,8 +2440,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, switch (rule->action) { case VIR_NWFILTER_RULE_ACTION_REJECT: /* REJECT not supported */ - target = virNWFilterJumpTargetTypeToString( - VIR_NWFILTER_RULE_ACTION_DROP); + target = virNWFilterJumpTargetTypeToString(VIR_NWFILTER_RULE_ACTION_DROP); break; default: target = virNWFilterJumpTargetTypeToString(rule->action); @@ -2722,7 +2720,7 @@ ebtablesRemoveSubChainsQuery(virFirewallPtr fw, virFirewallAddRuleFull(fw, VIR_FIREWALL_LAYER_ETHERNET, false, ebtablesRemoveSubChainsQuery, (void *)chainprefixes, - "-t", "nat", "-L", tmp, NULL); + "-t", "nat", "-L", tmp, NULL); virFirewallAddRuleFull(fw, VIR_FIREWALL_LAYER_ETHERNET, true, NULL, NULL, "-t", "nat", "-F", tmp, NULL); @@ -3161,7 +3159,7 @@ virNWFilterRuleInstSort(const void *a, const void *b) const virNWFilterRuleInst *insta = a; const virNWFilterRuleInst *instb = b; const char *root = virNWFilterChainSuffixTypeToString( - VIR_NWFILTER_CHAINSUFFIX_ROOT); + VIR_NWFILTER_CHAINSUFFIX_ROOT); bool root_a = STREQ(insta->chainSuffix, root); bool root_b = STREQ(instb->chainSuffix, root); @@ -3222,7 +3220,7 @@ iptablesCheckBridgeNFCallEnabled(bool isIPv6) char msg[256]; snprintf(msg, sizeof(msg), _("To enable ip%stables filtering for the VM do " - "'echo 1 > %s'"), + "'echo 1 > %s'"), isIPv6 ? "6" : "", pathname); VIR_WARN("%s", msg); @@ -3361,7 +3359,7 @@ ebtablesGetSubChainInsts(virHashTablePtr chains, for (i = 0; filter_names[i].key; i++) { struct ebtablesSubChainInst *inst; enum l3_proto_idx idx = ebtablesGetProtoIdxByFiltername( - filter_names[i].key); + filter_names[i].key); if ((int)idx < 0) continue; diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index 008c24b..28bd8ad 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -556,11 +556,9 @@ learnIPAddressThread(void *arg) /* packets from the VM */ if (etherType == ETHERTYPE_IP && - (header.len >= ethHdrSize + - sizeof(struct iphdr))) { + (header.len >= ethHdrSize + sizeof(struct iphdr))) { VIR_WARNINGS_NO_CAST_ALIGN - struct iphdr *iphdr = (struct iphdr*)(packet + - ethHdrSize); + struct iphdr *iphdr = (struct iphdr*)(packet + ethHdrSize); VIR_WARNINGS_RESET vmaddr = iphdr->saddr; /* skip mcast addresses (224.0.0.0 - 239.255.255.255), @@ -574,11 +572,10 @@ learnIPAddressThread(void *arg) howDetected = DETECT_STATIC; } else if (etherType == ETHERTYPE_ARP && - (header.len >= ethHdrSize + - sizeof(struct f_arphdr))) { + (header.len >= ethHdrSize + sizeof(struct f_arphdr))) { VIR_WARNINGS_NO_CAST_ALIGN struct f_arphdr *arphdr = (struct f_arphdr*)(packet + - ethHdrSize); + ethHdrSize); VIR_WARNINGS_RESET switch (ntohs(arphdr->arphdr.ar_op)) { case ARPOP_REPLY: @@ -597,32 +594,27 @@ learnIPAddressThread(void *arg) virMacAddrIsBroadcastRaw(ether_hdr->ether_dhost)) { /* packets to the VM */ if (etherType == ETHERTYPE_IP && - (header.len >= ethHdrSize + - sizeof(struct iphdr))) { + (header.len >= ethHdrSize + sizeof(struct iphdr))) { VIR_WARNINGS_NO_CAST_ALIGN - struct iphdr *iphdr = (struct iphdr*)(packet + - ethHdrSize); + struct iphdr *iphdr = (struct iphdr*)(packet + ethHdrSize); VIR_WARNINGS_RESET if ((iphdr->protocol == IPPROTO_UDP) && - (header.len >= ethHdrSize + - iphdr->ihl * 4 + - sizeof(struct udphdr))) { + (header.len >= + ethHdrSize + iphdr->ihl * 4 + sizeof(struct udphdr))) { VIR_WARNINGS_NO_CAST_ALIGN struct udphdr *udphdr = (struct udphdr *) ((char *)iphdr + iphdr->ihl * 4); VIR_WARNINGS_RESET if (ntohs(udphdr->source) == 67 && ntohs(udphdr->dest) == 68 && - header.len >= ethHdrSize + - iphdr->ihl * 4 + - sizeof(struct udphdr) + - sizeof(struct dhcp)) { + (header.len >= (ethHdrSize + iphdr->ihl * 4 + + sizeof(struct udphdr) + + sizeof(struct dhcp)))) { struct dhcp *dhcp = (struct dhcp *) ((char *)udphdr + sizeof(udphdr)); if (dhcp->op == 2 /* BOOTREPLY */ && - virMacAddrCmpRaw( - &req->binding->mac, - &dhcp->chaddr[0]) == 0) { + virMacAddrCmpRaw(&req->binding->mac, + &dhcp->chaddr[0]) == 0) { dhcp_opts_len = header.len - (ethHdrSize + iphdr->ihl * 4 + sizeof(struct udphdr) + @@ -670,7 +662,7 @@ learnIPAddressThread(void *arg) if ((inetaddr = virSocketAddrFormat(&sa)) != NULL) { if (virNWFilterIPAddrMapAddIPAddr(req->binding->portdevname, inetaddr) < 0) { VIR_ERROR(_("Failed to add IP address %s to IP address " - "cache for interface %s"), inetaddr, req->binding->portdevname); + "cache for interface %s"), inetaddr, req->binding->portdevname); } ret = virNWFilterInstantiateFilterLate(req->driver, -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/phyp/phyp_driver.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 05bf6df..96216c4 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1792,9 +1792,8 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml) ret = phypExecBuffer(session, &buf, &exit_status, conn, false); if (exit_status < 0 || ret == NULL) { - VIR_ERROR(_ - ("Possibly you don't have IBM Tools installed in your LPAR." - "Contact your support to enable this feature.")); + VIR_ERROR(_("Possibly you don't have IBM Tools installed in your LPAR." + " Contact your support to enable this feature.")); goto cleanup; } @@ -2825,9 +2824,8 @@ phypInterfaceDefineXML(virConnectPtr conn, const char *xml, if (system_type == HMC) virBufferAsprintf(&buf, "-m %s ", managed_system); - virBufferAsprintf(&buf, - " -r virtualio --rsubtype eth" - " -p %s -o r -s %d", def->name, slot); + virBufferAsprintf(&buf, " -r virtualio --rsubtype eth -p %s -o r -s %d", + def->name, slot); VIR_FREE(ret); ret = phypExecBuffer(session, &buf, &exit_status, conn, false); goto cleanup; @@ -3127,8 +3125,9 @@ phypConnectListDefinedDomains(virConnectPtr conn, char **const names, int nnames virBufferAddLit(&buf, "lssyscfg -r lpar"); if (system_type == HMC) virBufferAsprintf(&buf, " -m %s", managed_system); - virBufferAddLit(&buf, " -F name,state" - "|sed -n '/Not Activated/ {\n s/,.*$//\n p\n}'"); + virBufferAddLit(&buf, + " -F name,state" + "|sed -n '/Not Activated/ {\n s/,.*$//\n p\n}'"); ret = phypExecBuffer(session, &buf, &exit_status, conn, false); /* I need to parse the textual return in order to get the domains */ @@ -3605,7 +3604,7 @@ phypDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, if (nvcpus > phypDomainGetMaxVcpus(dom)) { VIR_ERROR(_("You are trying to set a number of CPUs bigger than " - "the max possible.")); + "the max possible.")); return 0; } @@ -3628,8 +3627,7 @@ phypDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, ret = phypExecBuffer(session, &buf, &exit_status, dom->conn, false); if (exit_status < 0) { - VIR_ERROR(_ - ("Possibly you don't have IBM Tools installed in your LPAR." + VIR_ERROR(_("Possibly you don't have IBM Tools installed in your LPAR." " Contact your support to enable this feature.")); } -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/remote/remote_daemon.c | 2 +- src/remote/remote_daemon_dispatch.c | 16 +++++++-------- src/remote/remote_driver.c | 31 +++++++++++++++-------------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index c14a561..c67f1b0 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -549,7 +549,7 @@ daemonSetupNetworking(virNetServerPtr srv, (ipsock && config->listen_tls && config->auth_tls == REMOTE_AUTH_SASL) || (ipsock && config->listen_tcp && config->auth_tcp == REMOTE_AUTH_SASL)) { saslCtxt = virNetSASLContextNewServer( - (const char *const*)config->sasl_allowed_username_list); + (const char *const*)config->sasl_allowed_username_list); if (!saslCtxt) goto cleanup; } diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index e62ebfb..50d2079 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -6004,10 +6004,10 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server ATTRIBUT static int remoteDispatchConnectStoragePoolEventDeregisterAny(virNetServerPtr server ATTRIBUTE_UNUSED, - virNetServerClientPtr client, - virNetMessagePtr msg ATTRIBUTE_UNUSED, - virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED, - remote_connect_storage_pool_event_deregister_any_args *args) + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED, + remote_connect_storage_pool_event_deregister_any_args *args) { int rv = -1; size_t i; @@ -6246,10 +6246,10 @@ remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server ATTRIBUTE_UNU static int remoteDispatchConnectSecretEventDeregisterAny(virNetServerPtr server ATTRIBUTE_UNUSED, - virNetServerClientPtr client, - virNetMessagePtr msg ATTRIBUTE_UNUSED, - virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED, - remote_connect_secret_event_deregister_any_args *args) + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED, + remote_connect_secret_event_deregister_any_args *args) { int rv = -1; size_t i; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 3b43e21..58528af 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -326,8 +326,8 @@ remoteDomainBuildEventCallbackBalloonChange(virNetClientProgramPtr prog, static void remoteDomainBuildEventPMSuspendDisk(virNetClientProgramPtr prog, - virNetClientPtr client, - void *evdata, void *opaque); + virNetClientPtr client, + void *evdata, void *opaque); static void remoteDomainBuildEventCallbackPMSuspendDisk(virNetClientProgramPtr prog, virNetClientPtr client, @@ -914,7 +914,7 @@ doRemoteOpen(virConnectPtr conn, } VIR_DEBUG("passing through variable '%s' ('%s') to remote end", - var->name, var->value); + var->name, var->value); } /* Construct the original name. */ @@ -1197,8 +1197,8 @@ doRemoteOpen(virConnectPtr conn, goto failed; if (virNetClientKeepAliveIsSupported(priv->client)) { - priv->serverKeepAlive = remoteConnectSupportsFeatureUnlocked(conn, - priv, VIR_DRV_FEATURE_PROGRAM_KEEPALIVE); + priv->serverKeepAlive = remoteConnectSupportsFeatureUnlocked( + conn, priv, VIR_DRV_FEATURE_PROGRAM_KEEPALIVE); if (!priv->serverKeepAlive) { VIR_INFO("Disabling keepalive protocol since it is not supported" " by the server"); @@ -1239,15 +1239,16 @@ doRemoteOpen(virConnectPtr conn, if (!(priv->eventState = virObjectEventStateNew())) goto failed; - priv->serverEventFilter = remoteConnectSupportsFeatureUnlocked(conn, - priv, VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK); + priv->serverEventFilter = remoteConnectSupportsFeatureUnlocked( + conn, priv, VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK); if (!priv->serverEventFilter) { VIR_INFO("Avoiding server event filtering since it is not " "supported by the server"); } - priv->serverCloseCallback = remoteConnectSupportsFeatureUnlocked(conn, - priv, VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK); + priv->serverCloseCallback = remoteConnectSupportsFeatureUnlocked( + conn, priv, + VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK); if (!priv->serverCloseCallback) { VIR_INFO("Close callback registering isn't supported " "by the remote side."); @@ -2913,9 +2914,9 @@ static int remoteDomainGetBlockJobInfo(virDomainPtr domain, if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_JOB_INFO, (xdrproc_t)xdr_remote_domain_get_block_job_info_args, - (char *)&args, + (char *)&args, (xdrproc_t)xdr_remote_domain_get_block_job_info_ret, - (char *)&ret) == -1) + (char *)&ret) == -1) goto done; if (ret.found) { @@ -2956,9 +2957,9 @@ static int remoteDomainGetBlockIoTune(virDomainPtr domain, if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_IO_TUNE, (xdrproc_t) xdr_remote_domain_get_block_io_tune_args, - (char *) &args, + (char *) &args, (xdrproc_t) xdr_remote_domain_get_block_io_tune_ret, - (char *) &ret) == -1) { + (char *) &ret) == -1) { goto done; } @@ -3426,7 +3427,7 @@ remoteConnectSecretEventRegisterAny(virConnectPtr conn, static int remoteConnectSecretEventDeregisterAny(virConnectPtr conn, - int callbackID) + int callbackID) { struct private_data *priv = conn->privateData; int rv = -1; @@ -8239,7 +8240,7 @@ make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src) static void make_nonnull_interface(remote_nonnull_interface *interface_dst, - virInterfacePtr interface_src) + virInterfacePtr interface_src) { interface_dst->name = interface_src->name; interface_dst->mac = interface_src->mac; -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/rpc/virnetclient.c | 40 +++++++++++++++++++---------------- src/rpc/virnetlibsshsession.c | 2 +- src/rpc/virnetservermdns.c | 4 ++-- src/rpc/virnetsocket.c | 23 +++++++++++--------- src/rpc/virnetsshsession.c | 2 +- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index b4d8fb2..d2162d4 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -493,15 +493,17 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host, if (!(nc = virBufferContentAndReset(&buf))) goto no_memory; - virBufferAsprintf(&buf, - "sh -c " - "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " - "ARG=-q0;" - "else " - "ARG=;" - "fi;" - "'%s' $ARG -U %s'", - nc, nc, socketPath); +#define COMMAND_FORMAT "sh -c " \ + "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " \ + "ARG=-q0;" \ + "else " \ + "ARG=;" \ + "fi;" \ + "'%s' $ARG -U %s'" + + virBufferAsprintf(&buf, COMMAND_FORMAT, nc, nc, socketPath); + +#undef COMMAND_FORMAT if (!(command = virBufferContentAndReset(&buf))) goto no_memory; @@ -601,17 +603,19 @@ virNetClientPtr virNetClientNewLibssh(const char *host, if (!(nc = virBufferContentAndReset(&buf))) goto no_memory; - if (virAsprintf(&command, - "sh -c " - "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " - "ARG=-q0;" - "else " - "ARG=;" - "fi;" - "'%s' $ARG -U %s'", - nc, nc, socketPath) < 0) +#define COMMAND_FORMAT "sh -c " \ + "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " \ + "ARG=-q0;" \ + "else " \ + "ARG=;" \ + "fi;" \ + "'%s' $ARG -U %s'" + + if (virAsprintf(&command, COMMAND_FORMAT, nc, nc, socketPath) < 0) goto cleanup; +#undef COMMAND_FORMAT + if (virNetSocketNewConnectLibssh(host, port, family, username, privkey, diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 7c5f158..2422150 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -1124,7 +1124,7 @@ virNetLibsshSessionAuthAddKeyboardAuth(virNetLibsshSessionPtr sess, int virNetLibsshSessionSetChannelCommand(virNetLibsshSessionPtr sess, - const char *command) + const char *command) { int ret = 0; virObjectLock(sess); diff --git a/src/rpc/virnetservermdns.c b/src/rpc/virnetservermdns.c index e0a9aef..3669998 100644 --- a/src/rpc/virnetservermdns.c +++ b/src/rpc/virnetservermdns.c @@ -347,8 +347,8 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U } VIR_DEBUG("Trigger timed for %d %d %d %d", - (int)now.tv_sec, (int)now.tv_usec, - (int)(tv ? tv->tv_sec : 0), (int)(tv ? tv->tv_usec : 0)); + (int)now.tv_sec, (int)now.tv_usec, + (int)(tv ? tv->tv_sec : 0), (int)(tv ? tv->tv_usec : 0)); nowms = (now.tv_sec * 1000ll) + (now.tv_usec / 1000ll); if (tv) { thenms = (tv->tv_sec * 1000ll) + (tv->tv_usec/1000ll); diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 55de3b2..5fe0930 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -634,7 +634,7 @@ int virNetSocketNewConnectUNIX(const char *path, bool daemonLaunched = false; VIR_DEBUG("path=%s spawnDaemon=%d binary=%s", path, spawnDaemon, - NULLSTR(binary)); + NULLSTR(binary)); memset(&localAddr, 0, sizeof(localAddr)); memset(&remoteAddr, 0, sizeof(remoteAddr)); @@ -883,14 +883,17 @@ int virNetSocketNewConnectSSH(const char *nodename, * Fedora's 'nc' doesn't have this option, and defaults to the desired * behavior. */ - virCommandAddArgFormat(cmd, - "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " - "ARG=-q0;" - "else " - "ARG=;" - "fi;" - "'%s' $ARG -U %s'", - quoted, quoted, path); +#define COMMAND_FORMAT "" \ + "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " \ + "ARG=-q0;" \ + "else " \ + "ARG=;" \ + "fi;" \ + "'%s' $ARG -U %s'" + + virCommandAddArgFormat(cmd, COMMAND_FORMAT, quoted, quoted, path); + +#undef COMMAND_FORMAT VIR_FREE(quoted); return virNetSocketNewConnectCommand(cmd, retsock); @@ -1534,7 +1537,7 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock, */ if (errno != EOPNOTSUPP) { virReportSystemError(errno, "%s", - _("Failed to get client socket PID")); + _("Failed to get client socket PID")); goto cleanup; } } diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index 35dc6c5..1114036 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -462,7 +462,7 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess) if (sess->knownHostsFile) { if (libssh2_knownhost_writefile(sess->knownHosts, sess->knownHostsFile, - LIBSSH2_KNOWNHOST_FILE_OPENSSH) < 0) { + LIBSSH2_KNOWNHOST_FILE_OPENSSH) < 0) { libssh2_session_last_error(sess->session, &errmsg, NULL, 0); virReportError(VIR_ERR_SSH, _("failed to write known_host file '%s': %s"), -- 2.17.1

This patch fixes misaligned arguments and misaligned conditions. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/storage/storage_backend_disk.c | 7 +++---- src/storage/storage_backend_gluster.c | 2 +- src/storage/storage_backend_iscsi_direct.c | 2 +- src/storage/storage_backend_rbd.c | 14 +++++++------- src/storage/storage_driver.c | 6 +++--- src/storage/storage_util.c | 16 +++++++--------- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 10df071..9176511 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -681,7 +681,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool, dev->geometry.sectors * SECTOR_SIZE; VIR_DEBUG("find free area: allocation %llu, cyl size %llu", allocation, - cylinderSize); + cylinderSize); int partType = virStorageBackendDiskPartTypeToCreate(pool); /* how many extra bytes we have since we allocate @@ -708,8 +708,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool, size -= SECTOR_SIZE; } if (size > neededSize && - (smallestSize == 0 || - size < smallestSize)) { + (smallestSize == 0 || size < smallestSize)) { /* for logical partition, the free extent must be within a logical free area */ if (partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL && @@ -798,7 +797,7 @@ virStorageBackendDiskDeleteVol(virStoragePoolObjPtr pool, if (!vol->target.path) { virReportError(VIR_ERR_INVALID_ARG, _("volume target path empty for source path '%s'"), - src_path); + src_path); return -1; } diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c index e09bc54..4a3c848 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -350,7 +350,7 @@ virStorageBackendGlusterRefreshPool(virStoragePoolObjPtr pool) struct dirent ent; /* See comment below about readdir_r needing padding */ char padding[MAX(1, 256 - (int)(sizeof(struct dirent) - - offsetof(struct dirent, d_name)))]; + - offsetof(struct dirent, d_name)))]; } de; struct dirent *ent; glfs_fd_t *dir = NULL; diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c index 5c1b251..1142050 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -669,7 +669,7 @@ virStorageBackendISCSIDirectVolWipeZero(virStorageVolDefPtr vol, lba += BLOCK_PER_PACKET; } else { if (!(task = iscsi_write10_sync(iscsi, lun, lba, data, block_size, - block_size, 0, 0, 0, 0, 0))) + block_size, 0, 0, 0, 0, 0))) goto cleanup; scsi_free_scsi_task(task); lba++; diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index 2cba678..f91a6bf 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -136,7 +136,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr, virBufferAsprintf(&mon_host, "%s,", source->hosts[i].name); } else if (source->hosts[i].name != NULL && - source->hosts[i].port) { + source->hosts[i].port) { virBufferAsprintf(&mon_host, "%s:%d,", source->hosts[i].name, source->hosts[i].port); @@ -281,7 +281,7 @@ volStorageBackendRBDGetFeatures(rbd_image_t image, if ((r = rbd_get_features(image, features)) < 0) { virReportSystemError(-r, _("failed to get the features of RBD image " - "%s"), volname); + "%s"), volname); goto cleanup; } ret = 0; @@ -397,7 +397,7 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol, } VIR_DEBUG("Refreshed RBD image %s/%s (capacity: %llu allocation: %llu " - "obj_size: %"PRIu64" num_objs: %"PRIu64")", + "obj_size: %"PRIu64" num_objs: %"PRIu64")", def->source.name, vol->name, vol->target.capacity, vol->target.allocation, info.obj_size, info.num_objs); @@ -895,7 +895,7 @@ virStorageBackendRBDSnapshotCreate(rbd_image_t image, if ((r = rbd_snap_create(image, snapname)) < 0) { virReportSystemError(-r, _("failed to create RBD snapshot %s@%s"), - imgname, snapname); + imgname, snapname); goto cleanup; } @@ -928,7 +928,7 @@ virStorageBackendRBDSnapshotProtect(rbd_image_t image, if ((r = rbd_snap_protect(image, snapname)) < 0) { virReportSystemError(-r, _("failed to protect RBD snapshot %s@%s"), - imgname, snapname); + imgname, snapname); goto cleanup; } } else { @@ -1140,7 +1140,7 @@ virStorageBackendRBDVolWipeZero(rbd_image_t image, if ((r = rbd_write(image, offset, length, writebuf)) < 0) { virReportSystemError(-r, _("writing %llu bytes failed on " "RBD image %s at offset %llu"), - length, imgname, offset); + length, imgname, offset); goto cleanup; } @@ -1177,7 +1177,7 @@ virStorageBackendRBDVolWipeDiscard(rbd_image_t image, if ((r = rbd_discard(image, offset, length)) < 0) { virReportSystemError(-r, _("discarding %llu bytes failed on " "RBD image %s at offset %llu"), - length, imgname, offset); + length, imgname, offset); goto cleanup; } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 7c22c43..d9d6be7 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -273,9 +273,9 @@ storageStateInitialize(bool privileged, goto error; if ((virAsprintf(&driver->configDir, - "%s/storage", configdir) < 0) || + "%s/storage", configdir) < 0) || (virAsprintf(&driver->autostartDir, - "%s/storage/autostart", configdir) < 0) || + "%s/storage/autostart", configdir) < 0) || (virAsprintf(&driver->stateDir, "%s/storage/run", rundir) < 0)) goto error; @@ -586,7 +586,7 @@ storageConnectNumOfDefinedStoragePools(virConnectPtr conn) return -1; return virStoragePoolObjNumOfStoragePools(driver->pools, conn, false, - virConnectNumOfDefinedStoragePoolsCheckACL); + virConnectNumOfDefinedStoragePoolsCheckACL); } diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 318a556..5532221 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1537,7 +1537,7 @@ virStorageBackendDetectBlockVolFormatFD(virStorageSourcePtr target, if (disk_types[i].offset + disk_types[i].length > bytes) continue; if (memcmp(buffer+disk_types[i].offset, &disk_types[i].magic, - disk_types[i].length) == 0) { + disk_types[i].length) == 0) { target->format = disk_types[i].part_table_type; break; } @@ -3760,13 +3760,11 @@ virStorageBackendSCSISerial(const char *dev) { char *serial = NULL; #ifdef WITH_UDEV - virCommandPtr cmd = virCommandNewArgList( - "/lib/udev/scsi_id", - "--replace-whitespace", - "--whitelisted", - "--device", dev, - NULL - ); + virCommandPtr cmd = virCommandNewArgList("/lib/udev/scsi_id", + "--replace-whitespace", + "--whitelisted", + "--device", dev, + NULL); /* Run the program and capture its output */ virCommandSetOutputBuffer(cmd, &serial); @@ -4156,7 +4154,7 @@ processLU(virStoragePoolObjPtr pool, int virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, - uint32_t scanhost) + uint32_t scanhost) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); int retval = 0; -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/uml/uml_driver.c | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index d1c71d8..73f1868 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -192,8 +192,8 @@ umlAutostartDomain(virDomainObjPtr vm, } else { virObjectEventPtr event = virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_STARTED, - VIR_DOMAIN_EVENT_STARTED_BOOTED); + VIR_DOMAIN_EVENT_STARTED, + VIR_DOMAIN_EVENT_STARTED_BOOTED); virObjectEventStateQueue(data->driver->domainEventState, event); } } @@ -342,8 +342,8 @@ umlInotifyEvent(int watch, umlShutdownVMDaemon(driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN); virDomainAuditStop(dom, "shutdown"); event = virDomainEventLifecycleNewFromObj(dom, - VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); + VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); if (!dom->persistent) virDomainObjListRemove(driver->domains, dom); } else if (e.mask & (IN_CREATE | IN_MODIFY)) { @@ -373,8 +373,8 @@ umlInotifyEvent(int watch, VIR_DOMAIN_SHUTOFF_FAILED); virDomainAuditStop(dom, "failed"); event = virDomainEventLifecycleNewFromObj(dom, - VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_FAILED); + VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_FAILED); if (!dom->persistent) virDomainObjListRemove(driver->domains, dom); } else if (umlIdentifyChrPTY(driver, dom) < 0) { @@ -383,8 +383,8 @@ umlInotifyEvent(int watch, VIR_DOMAIN_SHUTOFF_FAILED); virDomainAuditStop(dom, "failed"); event = virDomainEventLifecycleNewFromObj(dom, - VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_FAILED); + VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_FAILED); if (!dom->persistent) virDomainObjListRemove(driver->domains, dom); } @@ -606,8 +606,8 @@ static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque) if (newVM) { virObjectEventPtr event = virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_DEFINED, - VIR_DOMAIN_EVENT_DEFINED_ADDED); + VIR_DOMAIN_EVENT_DEFINED, + VIR_DOMAIN_EVENT_DEFINED_ADDED); virObjectEventStateQueue(driver->domainEventState, event); } } @@ -736,8 +736,8 @@ static int umlProcessAutoDestroyDom(void *payload, umlShutdownVMDaemon(data->driver, dom, VIR_DOMAIN_SHUTOFF_DESTROYED); virDomainAuditStop(dom, "destroyed"); event = virDomainEventLifecycleNewFromObj(dom, - VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_DESTROYED); + VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_DESTROYED); if (!dom->persistent) virDomainObjListRemove(data->driver->domains, dom); @@ -1154,7 +1154,7 @@ static void umlShutdownVMDaemon(struct uml_driver *driver, if ((ret = waitpid(vm->pid, NULL, 0)) != vm->pid) { VIR_WARN("Got unexpected pid %d != %d", - ret, vm->pid); + ret, vm->pid); } vm->pid = -1; @@ -1323,7 +1323,7 @@ static int umlGetProcessInfo(unsigned long long *cpuTime, pid_t pid) static virDomainPtr umlDomainLookupByID(virConnectPtr conn, - int id) + int id) { struct uml_driver *driver = (struct uml_driver *)conn->privateData; virDomainObjPtr vm; @@ -1370,7 +1370,7 @@ static virDomainPtr umlDomainLookupByUUID(virConnectPtr conn, } static virDomainPtr umlDomainLookupByName(virConnectPtr conn, - const char *name) + const char *name) { struct uml_driver *driver = (struct uml_driver *)conn->privateData; virDomainObjPtr vm; @@ -1566,8 +1566,8 @@ static virDomainPtr umlDomainCreateXML(virConnectPtr conn, const char *xml, } virDomainAuditStart(vm, "booted", true); event = virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_STARTED, - VIR_DOMAIN_EVENT_STARTED_BOOTED); + VIR_DOMAIN_EVENT_STARTED, + VIR_DOMAIN_EVENT_STARTED_BOOTED); dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); @@ -1639,8 +1639,8 @@ umlDomainDestroyFlags(virDomainPtr dom, umlShutdownVMDaemon(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED); virDomainAuditStop(vm, "destroyed"); event = virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_DESTROYED); + VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_DESTROYED); if (!vm->persistent) virDomainObjListRemove(driver->domains, vm); ret = 0; @@ -1758,7 +1758,7 @@ static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem) } static int umlDomainGetInfo(virDomainPtr dom, - virDomainInfoPtr info) + virDomainInfoPtr info) { struct uml_driver *driver = dom->conn->privateData; virDomainObjPtr vm; @@ -1901,8 +1901,8 @@ static int umlDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) virDomainAuditStart(vm, "booted", ret >= 0); if (ret == 0) event = virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_STARTED, - VIR_DOMAIN_EVENT_STARTED_BOOTED); + VIR_DOMAIN_EVENT_STARTED, + VIR_DOMAIN_EVENT_STARTED_BOOTED); cleanup: virDomainObjEndAPI(&vm); @@ -2240,7 +2240,7 @@ umlDomainDetachDeviceFlags(virDomainPtr dom, static int umlDomainGetAutostart(virDomainPtr dom, - int *autostart) + int *autostart) { struct uml_driver *driver = dom->conn->privateData; virDomainObjPtr vm; @@ -2263,7 +2263,7 @@ static int umlDomainGetAutostart(virDomainPtr dom, } static int umlDomainSetAutostart(virDomainPtr dom, - int autostart) + int autostart) { struct uml_driver *driver = dom->conn->privateData; virDomainObjPtr vm; @@ -2437,7 +2437,7 @@ umlDomainOpenConsole(virDomainPtr dom, if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("character device %s is not using a PTY"), + _("character device %s is not using a PTY"), dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; } -- 2.17.1

This patch fixes misaligned arguments and misaligned conditions. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/vmware/vmware_conf.c | 2 +- src/vmware/vmware_driver.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 89ed639..3f4db2e 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -152,7 +152,7 @@ vmwareLoadDomains(struct vmware_driver *driver) goto cleanup; for (str = outbuf; (vmxPath = strtok_r(str, "\n", &saveptr)) != NULL; - str = NULL) { + str = NULL) { if (vmxPath[0] != '/') continue; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index f94b325..beaa847 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -206,8 +206,9 @@ vmwareConnectOpen(virConnectPtr conn, goto cleanup; if ((tmp = STRSKIP(conn->uri->scheme, "vmware")) == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to parse URI " - "scheme '%s'"), conn->uri->scheme); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to parse URI scheme '%s'"), + conn->uri->scheme); goto cleanup; } @@ -215,8 +216,9 @@ vmwareConnectOpen(virConnectPtr conn, driver->type = vmwareDriverTypeFromString(tmp); if (driver->type == -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to find valid " - "requested VMware backend '%s'"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to find valid requested VMware backend '%s'"), + tmp); goto cleanup; } -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/vmx/vmx.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 937bf0c..3016f4f 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -803,8 +803,8 @@ virVMXGetConfigLong(virConfPtr conf, const char *name, long long *number, *number = -1; } else if (virStrToLong_ll(string, NULL, 10, number) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Config entry '%s' must represent an integer value"), - name); + _("Config entry '%s' must represent an integer value"), + name); goto cleanup; } @@ -1183,9 +1183,8 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def, if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI && disk->info.addr.drive.controller == controller->idx) { - if (ctx->autodetectSCSIControllerModel - (disk, &autodetectedModels[count], - ctx->opaque) < 0) { + if (ctx->autodetectSCSIControllerModel( + disk, &autodetectedModels[count], ctx->opaque) < 0) { goto cleanup; } @@ -1667,8 +1666,8 @@ virVMXParseConfig(virVMXContext *ctx, } if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM, - VIR_DOMAIN_DISK_BUS_SCSI, controller, unit, - &def->disks[def->ndisks], def) < 0) { + VIR_DOMAIN_DISK_BUS_SCSI, controller, unit, + &def->disks[def->ndisks], def) < 0) { goto cleanup; } @@ -1904,7 +1903,7 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def) if (port < 0) { VIR_WARN("VNC is enabled but VMX entry 'RemoteDisplay.vnc.port' " - "is missing, the VNC port is unknown"); + "is missing, the VNC port is unknown"); (*def)->data.vnc.port = 0; (*def)->data.vnc.autoport = true; @@ -3316,8 +3315,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe if (scsi_virtualDev[i] != -1) { virBufferAsprintf(&buffer, "scsi%zu.virtualDev = \"%s\"\n", i, - virVMXControllerModelSCSITypeToString - (scsi_virtualDev[i])); + virVMXControllerModelSCSITypeToString( + scsi_virtualDev[i])); } } } @@ -3461,7 +3460,7 @@ virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer) if (def->data.vnc.autoport) { VIR_WARN("VNC autoport is enabled, but the automatically assigned " - "VNC port cannot be read back"); + "VNC port cannot be read back"); } else { if (def->data.vnc.port < 5900 || def->data.vnc.port > 5964) { VIR_WARN("VNC port %d it out of [5900..5964] range", @@ -3918,7 +3917,7 @@ virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported character device TCP protocol '%s'"), virDomainChrTcpProtocolTypeToString( - def->source->data.tcp.protocol)); + def->source->data.tcp.protocol)); return -1; } -- 2.17.1

This patch fixes misaligned arguments and misaligned conditions. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/vz/vz_driver.c | 14 +++++++------- src/vz/vz_sdk.c | 26 ++++++++++++++------------ src/vz/vz_utils.c | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index bedc631..0900ff3 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1844,8 +1844,8 @@ vzDomainBlockStatsFlags(virDomainPtr domain, static int vzDomainInterfaceStats(virDomainPtr domain, - const char *device, - virDomainInterfaceStatsPtr stats) + const char *device, + virDomainInterfaceStatsPtr stats) { virDomainObjPtr dom = NULL; vzDomObjPtr privdom; @@ -2157,8 +2157,8 @@ vzSnapObjFromSnapshot(virDomainSnapshotObjListPtr snapshots, static int vzCurrentSnapshotIterator(void *payload, - const void *name ATTRIBUTE_UNUSED, - void *data) + const void *name ATTRIBUTE_UNUSED, + void *data) { virDomainSnapshotObjPtr snapshot = payload; virDomainSnapshotObjPtr *current = data; @@ -2569,7 +2569,7 @@ vzDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned int flags) static int vzDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, - unsigned int flags) + unsigned int flags) { virDomainObjPtr dom; int ret = -1; @@ -2790,8 +2790,8 @@ vzBakeCookie(vzDriverPtr driver, if (flags & VZ_MIGRATION_COOKIE_DOMAIN_NAME) { /* if dom is NULL just pass some name for backward compat. * It is not used by peer */ - virBufferAsprintf(&buf, "<name>%s</name>\n", dom ? dom->def->name : - "__fakename__"); + virBufferAsprintf(&buf, "<name>%s</name>\n", + dom ? dom->def->name : "__fakename__"); } virBufferAdjustIndent(&buf, -2); diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 5ca906e..e73a750 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1003,8 +1003,8 @@ prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDefPtr net) if (*gw != '\0') { if (!(route = virNetDevIPRouteCreate(_("Domain interface"), - "ipv4", VIR_SOCKET_ADDR_IPV4_ALL, - NULL, gw, 0, true, 0, false))) + "ipv4", VIR_SOCKET_ADDR_IPV4_ALL, + NULL, gw, 0, true, 0, false))) goto cleanup; if (VIR_APPEND_ELEMENT(net->guestIP.routes, net->guestIP.nroutes, route) < 0) @@ -1013,8 +1013,8 @@ prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDefPtr net) if (*gw6 != '\0') { if (!(route = virNetDevIPRouteCreate(_("Domain interface"), - "ipv6", VIR_SOCKET_ADDR_IPV6_ALL, - NULL, gw6, 0, true, 0, false))) + "ipv6", VIR_SOCKET_ADDR_IPV6_ALL, + NULL, gw6, 0, true, 0, false))) goto cleanup; if (VIR_APPEND_ELEMENT(net->guestIP.routes, net->guestIP.nroutes, route) < 0) @@ -2897,7 +2897,7 @@ static int prlsdkCheckSerialUnsupportedParams(virDomainChrDefPtr chr) } if (chr->source->type == VIR_DOMAIN_CHR_TYPE_TCP && - chr->source->data.tcp.protocol != VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW) { + chr->source->data.tcp.protocol != VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Protocol '%s' is not supported for " "tcp character device."), @@ -3078,8 +3078,9 @@ static int prlsdkApplyGraphicsParams(PRL_HANDLE sdkdom, } glisten = virDomainGraphicsGetListen(gr, 0); - pret = PrlVmCfg_SetVNCHostName(sdkdom, glisten && glisten->address ? - glisten->address : VIR_LOOPBACK_IPV4_ADDR); + pret = PrlVmCfg_SetVNCHostName(sdkdom, + glisten && glisten->address ? + glisten->address : VIR_LOOPBACK_IPV4_ADDR); prlsdkCheckRetGoto(pret, cleanup); ret = 0; @@ -3219,10 +3220,10 @@ static int prlsdkConfigureGateways(PRL_HANDLE sdknet, virDomainNetDefPtr net) gateway = virNetDevIPRouteGetGateway(net->guestIP.routes[i]); ignore_value(virSocketAddrParse(&zero, - (VIR_SOCKET_ADDR_IS_FAMILY(addrdst, AF_INET) - ? VIR_SOCKET_ADDR_IPV4_ALL - : VIR_SOCKET_ADDR_IPV6_ALL), - VIR_SOCKET_ADDR_FAMILY(addrdst))); + (VIR_SOCKET_ADDR_IS_FAMILY(addrdst, AF_INET) + ? VIR_SOCKET_ADDR_IPV4_ALL + : VIR_SOCKET_ADDR_IPV6_ALL), + VIR_SOCKET_ADDR_FAMILY(addrdst))); /* virSocketAddrParse raises an error * and we are not going to report it, reset it expicitly*/ virResetLastError(); @@ -3419,7 +3420,8 @@ static int prlsdkConfigureNet(vzDriverPtr driver ATTRIBUTE_UNUSED, } pret = PrlVmDevNet_SetPktFilterPreventMacSpoof(sdknet, - net->trustGuestRxFilters == VIR_TRISTATE_BOOL_YES); + (net->trustGuestRxFilters == + VIR_TRISTATE_BOOL_YES)); prlsdkCheckRetGoto(pret, cleanup); ret = 0; diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index 13f5dee..384badd 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -481,7 +481,7 @@ int vzGetDefaultSCSIModel(vzDriverPtr driver, virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown SCSI controller model %s"), virDomainControllerModelSCSITypeToString( - driver->vzCaps.scsiControllerModel)); + driver->vzCaps.scsiControllerModel)); return -1; } return 0; -- 2.17.1

This patch fixes misaligned arguments. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/xenapi/xenapi_utils.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index 723f348..fee63c9 100644 --- a/src/xenapi/xenapi_utils.c +++ b/src/xenapi/xenapi_utils.c @@ -56,7 +56,7 @@ xenSessionFree(xen_session *session) char * xenapiUtil_RequestPassword(virConnectAuthPtr auth, const char *username, - const char *hostname) + const char *hostname) { unsigned int ncred; virConnectCredential cred; @@ -107,7 +107,8 @@ xenapiUtil_ParseQuery(virConnectPtr conn, virURIPtr uri, int *noVerify) if (virStrToLong_i(queryParam->value, NULL, 10, noVerify) < 0 || (*noVerify != 0 && *noVerify != 1)) { xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG, - _("Query parameter 'no_verify' has unexpected value (should be 0 or 1)")); + _("Query parameter 'no_verify' has " + "unexpected value (should be 0 or 1)")); goto failure; } } @@ -344,8 +345,9 @@ allocStringMap(xen_string_string_map **strings, char *key, char *val) { int sz = ((*strings) == NULL) ? 0 : (*strings)->size; sz++; - if (VIR_REALLOC_N(*strings, sizeof(xen_string_string_map) + - sizeof(xen_string_string_map_contents) * sz) < 0) + if (VIR_REALLOC_N(*strings, + (sizeof(xen_string_string_map) + + sizeof(xen_string_string_map_contents) * sz)) < 0) return -1; (*strings)->size = sz; if (VIR_STRDUP((*strings)->contents[sz-1].key, key) < 0 || @@ -532,7 +534,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def, (*record)->xenstore_data = xen_string_string_map_alloc(0); (*record)->hvm_shadow_multiplier = 1.000; if (!xen_vm_create(((struct _xenapiPrivate *)(conn->privateData))->session, - vm, *record)) { + vm, *record)) { xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL); return -1; } -- 2.17.1

This patch fixes misaligned arguments and misaligned conditions. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- src/xenconfig/xen_common.c | 21 +++++++++++++-------- src/xenconfig/xen_xl.c | 23 +++++++++++------------ src/xenconfig/xen_xm.c | 8 ++++---- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 0a99587..d1d5b9a 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -295,11 +295,11 @@ xenParseMem(virConfPtr conf, virDomainDefPtr def) unsigned long long memory; if (xenConfigGetULongLong(conf, "memory", &def->mem.cur_balloon, - MIN_XEN_GUEST_SIZE * 2) < 0) + MIN_XEN_GUEST_SIZE * 2) < 0) return -1; if (xenConfigGetULongLong(conf, "maxmem", &memory, - def->mem.cur_balloon) < 0) + def->mem.cur_balloon) < 0) return -1; def->mem.cur_balloon *= 1024; @@ -1104,8 +1104,12 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN); - if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type, - VIR_ARCH_NONE, def->virtType, NULL, NULL))) + if (!(capsdata = virCapabilitiesDomainDataLookup(caps, + def->os.type, + VIR_ARCH_NONE, + def->virtType, + NULL, + NULL))) goto out; def->os.arch = capsdata->arch; @@ -1680,17 +1684,17 @@ xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def) if (hvm) { if (xenConfigSetInt(conf, "pae", (def->features[VIR_DOMAIN_FEATURE_PAE] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) return -1; if (xenConfigSetInt(conf, "acpi", (def->features[VIR_DOMAIN_FEATURE_ACPI] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) return -1; if (xenConfigSetInt(conf, "apic", (def->features[VIR_DOMAIN_FEATURE_APIC] == - VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) + VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0) return -1; if (def->features[VIR_DOMAIN_FEATURE_HAP] == VIR_TRISTATE_SWITCH_OFF) { @@ -1805,7 +1809,8 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) return -1; if (xenConfigSetInt(conf, "vncunused", - def->graphics[0]->data.vnc.autoport ? 1 : 0) < 0) + (def->graphics[0]->data.vnc.autoport ? + 1 : 0)) < 0) return -1; if (!def->graphics[0]->data.vnc.autoport && diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 7250e57..2afaa25 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -467,8 +467,7 @@ xenParseXLVnuma(virConfPtr conf, const char *data; const char *str = vnode->str; - if (!str || - !(data = strrchr(str, '='))) { + if (!str || !(data = strrchr(str, '='))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("vnuma vnode invalid format '%s'"), str); @@ -545,8 +544,9 @@ xenParseXLVnuma(virConfPtr conf, if (ndistances != nr_nodes) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("vnuma pnode %d configured '%s' (count %zu) doesn't fit the number of specified vnodes %zu"), - pnode, str, ndistances, nr_nodes); + _("vnuma pnode %d configured '%s' (count %zu)" + " doesn't fit the number of specified vnodes %zu"), + pnode, str, ndistances, nr_nodes); goto cleanup; } @@ -844,9 +844,9 @@ xenParseXLInputDevs(virConfPtr conf, virDomainDefPtr def) str = val->str; if (str && - (STREQ(str, "tablet") || - STREQ(str, "mouse") || - STREQ(str, "keyboard"))) { + (STREQ(str, "tablet") || + STREQ(str, "mouse") || + STREQ(str, "keyboard"))) { virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) return -1; @@ -1288,7 +1288,7 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def) /* XXX floppy disks */ } else { if (def->os.bootloader && - xenConfigSetString(conf, "bootloader", def->os.bootloader) < 0) + xenConfigSetString(conf, "bootloader", def->os.bootloader) < 0) return -1; if (def->os.bootloaderArgs && @@ -1337,9 +1337,8 @@ xenFormatXLCPUID(virConfPtr conf, virDomainDefPtr def) j = 1; for (i = 0; i < def->cpu->nfeatures; i++) { - const char *feature_name = xenTranslateCPUFeature( - def->cpu->features[i].name, - false); + const char *feature_name = xenTranslateCPUFeature(def->cpu->features[i].name, + false); const char *policy = NULL; if (STREQ(feature_name, "vmx") || STREQ(feature_name, "svm")) @@ -1453,7 +1452,7 @@ xenFormatXLVnuma(virConfValuePtr list, virBufferAddLit(&buf, "vdistances="); for (i = 0; i < nr_nodes; i++) { virBufferAsprintf(&buf, "%zu", - virDomainNumaGetNodeDistance(numa, node, i)); + virDomainNumaGetNodeDistance(numa, node, i)); if ((nr_nodes - i) > 1) virBufferAddLit(&buf, ","); } diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c index 909e8fa..96f046b 100644 --- a/src/xenconfig/xen_xm.c +++ b/src/xenconfig/xen_xm.c @@ -424,9 +424,9 @@ xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def) if (xenConfigGetString(conf, "usbdevice", &str, NULL) < 0) return -1; if (str && - (STREQ(str, "tablet") || - STREQ(str, "mouse") || - STREQ(str, "keyboard"))) { + (STREQ(str, "tablet") || + STREQ(str, "mouse") || + STREQ(str, "keyboard"))) { virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) return -1; @@ -532,7 +532,7 @@ xenFormatXMOS(virConfPtr conf, virDomainDefPtr def) /* XXX floppy disks */ } else { if (def->os.bootloader && - xenConfigSetString(conf, "bootloader", def->os.bootloader) < 0) + xenConfigSetString(conf, "bootloader", def->os.bootloader) < 0) return -1; if (def->os.bootloaderArgs && -- 2.17.1

Linefeed can be put behind the open-parenthesis of the function, the position of argument should be: 1) pos % 4 == 0 2) pos > start_of_function_name(includes func's parent_pointer) 3) pos is the first place which matches 1) and 2) E.g. [indent]if (virLongLongLongFunctionName( [4-spaces-align]LongLongLongFirstName, [4-spaces-align]LongLongLongSecondName) < 0) or [indent]ret = pointer->virFunctionName( [4-spaces-align]LongLongLongFirstName, [4-spaces-align]LongLongLongSecondName); Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- build-aux/check-spacing.pl | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index d36b004..64a5dac 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -275,10 +275,10 @@ sub CheckMisalignment { my $pos = $$paren_stack[-1][0]; my $linenum = $$paren_stack[-1][1]; my $code = $$paren_stack[-1][2]; - if ($pos + 1 != length($`)) { + if ($pos != length($`)) { my $pad = ""; if ($. > $linenum + 1) { - $pad = " " x $pos . " ...\n"; + $pad = " " x $pos . "...\n"; } print "Misaligned line in parenthesis:\n"; print "$$file:$linenum-$.:\n$code$pad$$line\n"; @@ -291,6 +291,7 @@ sub CheckMisalignment { if ($$data =~ /.*[()]/) { my $pos = 0; my $temp = $$data; + $temp =~ s/\s+$//; # Kill the content between matched parenthesis and themselves # within the current line. @@ -310,9 +311,20 @@ sub CheckMisalignment { } # Push the item for open-paren on @paren_stack - # @item = [ position of the open-paren, linenum, code-line ] + # @item = [ correct-indent, linenum, code-line ] while (($pos = index($temp, "\(", $pos)) >= 0) { - push @$paren_stack, [$pos, $., $$line]; + if ($pos+1 == length($temp)) { + my $recent = rindex($temp, "\(", $pos-1) + 1; + my $correct = rindex($temp, " ", $pos-1) + 1; + $correct = ($correct >= $recent) ? $correct : $recent; + $correct += 4 - ($correct % 4); + if ($correct < $pos) { + push @$paren_stack, [$correct, $., $$line]; + last; + } + } + + push @$paren_stack, [$pos+1, $., $$line]; $pos++; } } @@ -370,7 +382,7 @@ foreach my $file (@ARGV) { # We _need_ fix these misalignment in batches. # We _should_ remove it as soon as fixing all. ##################################################################### - next unless $file =~ /^src\/util\//; + next unless $file =~ /^src\/(?!esx|qemu|hyperv|lxc|conf|libxl|vbox|test|security)/; $ret = 1 if CheckMisalignment(\$data, \$file, \$line, \@paren_stack); } -- 2.17.1

This patch definitely indicates the correct position for misaligned stuff. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- build-aux/check-spacing.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index 64a5dac..478e7ab 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -277,11 +277,22 @@ sub CheckMisalignment { my $code = $$paren_stack[-1][2]; if ($pos != length($`)) { my $pad = ""; + my $indicator = ""; if ($. > $linenum + 1) { $pad = " " x $pos . "...\n"; } print "Misaligned line in parenthesis:\n"; - print "$$file:$linenum-$.:\n$code$pad$$line\n"; + print "$$file:$linenum-$.:\n$code$pad$$line"; + if ($pos > length($`)) { + $indicator = " " x length($`); + $indicator .= "~" x ($pos - length($`)); + $indicator .= "^"; + } else { + $indicator = " " x $pos; + $indicator .= "^"; + $indicator .= "~" x (length($`) - $pos); + } + print "$indicator\n"; $ret = 1; } } -- 2.17.1

This patch replaces those 'my varname;' with 'our varname;', i.e. it uses global var, rather than passing arguments to subroutine. So it can be a bit faster. Signed-off-by: Shi Lei <shi_lei@massclouds.com> --- build-aux/check-spacing.pl | 218 ++++++++++++++++++------------------- 1 file changed, 107 insertions(+), 111 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index 478e7ab..9e2a2a4 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -23,12 +23,15 @@ use strict; use warnings; +our $ret = 0; + # # CheckFunctionBody: # $_[0]: $data(in) -# $_[1]: $location(in), which format is file-path:line-num:line-code -# $_[2]: $fn_linenum(inout), maintains start line-num of function body -# Returns 0 in case of success or 1 on failure +# $_[1]: $file(in) +# $_[2]: $line(in) +# $_[3]: $fn_linenum(inout), maintains start line-num of function body +# Set $ret 1 on failure # # Check incorrect indentation and blank first line in function body. # For efficiency, it only checks the first line of function body. @@ -37,29 +40,28 @@ use warnings; # move it into this subroutine. But *state* requires version >= v5.10.) # sub CheckFunctionBody { - my $ret = 0; - my ($data, $location, $fn_linenum) = @_; + our ($data, $file, $line, $fn_linenum); # Check first line of function block - if ($$fn_linenum) { - if ($$data =~ /^\s*$/) { - print "Blank line before content in function body:\n$$location"; + if ($fn_linenum) { + if ($data =~ /^\s*$/) { + print "Blank line before content in function body:\n"; + print "$file:$.:\n$line"; $ret = 1; - } elsif ($$data !~ /^[ ]{4}\S/) { - unless ($$data =~ /^[ ]\w+:$/ || $$data =~ /^}/) { - print "Incorrect indentation in function body:\n$$location"; + } elsif ($data !~ /^[ ]{4}\S/) { + unless ($data =~ /^[ ]\w+:$/ || $data =~ /^}/) { + print "Incorrect indentation in function body:\n"; + print "$file:$.:\n$line"; $ret = 1; } } - $$fn_linenum = 0; + $fn_linenum = 0; } # Detect start of function block - if ($$data =~ /^{$/) { - $$fn_linenum = $.; + if ($data =~ /^{$/) { + $fn_linenum = $.; } - - return $ret; } # @@ -71,42 +73,40 @@ sub CheckFunctionBody { # (Also, the @incomment could be declared with *state* and move it in.) # sub KillComments { - my ($data, $incomment) = @_; + our ($data, $incomment); # Kill contents of multi-line comments # and detect end of multi-line comments - if ($$incomment) { - if ($$data =~ m,\*/,) { - $$incomment = 0; - $$data =~ s,^.*\*/,*/,; + if ($incomment) { + if ($data =~ m,\*/,) { + $incomment = 0; + $data =~ s,^.*\*/,*/,; } else { - $$data = ""; + $data = ""; } } # Kill single line comments, and detect # start of multi-line comments - if ($$data =~ m,/\*.*\*/,) { - $$data =~ s,/\*.*\*/,/* */,; - } elsif ($$data =~ m,/\*,) { - $$incomment = 1; - $$data =~ s,/\*.*,/*,; + if ($data =~ m,/\*.*\*/,) { + $data =~ s,/\*.*\*/,/* */,; + } elsif ($data =~ m,/\*,) { + $incomment = 1; + $data =~ s,/\*.*,/*,; } - - return; } # # CheckWhiteSpaces: # $_[0]: $data(in) -# $_[1]: $location(in), which format is file-path:line-num:line-code -# Returns 0 in case of success or 1 on failure +# $_[1]: $file(in) +# $_[1]: $line(in) +# Set $ret on failure # # Check whitespaces according to code spec of libvirt. # sub CheckWhiteSpaces { - my $ret = 0; - my ($data, $location) = @_; + our ($data, $file, $line); # We need to match things like # @@ -126,7 +126,7 @@ sub CheckWhiteSpaces { # later on. # For temporary modifications - my $tmpdata = $$data; + my $tmpdata = $data; while ($tmpdata =~ /(\w+)\s\((?!\*)/) { my $kw = $1; @@ -134,30 +134,34 @@ sub CheckWhiteSpaces { if ($kw =~ /^(?:if|for|while|switch|return)$/) { $tmpdata =~ s/(?:$kw\s\()/XXX(/; } else { - print "Whitespace after non-keyword:\n$$location"; + print "Whitespace after non-keyword:\n"; + print "$file:$.:\n$line"; $ret = 1; last; } } # Require whitespace immediately after keywords - if ($$data =~ /\b(?:if|for|while|switch|return)\(/) { - print "No whitespace after keyword:\n$$location"; + if ($data =~ /\b(?:if|for|while|switch|return)\(/) { + print "No whitespace after keyword:\n"; + print "$file:$.:\n$line"; $ret = 1; } # Forbid whitespace between )( of a function typedef - if ($$data =~ /\(\*\w+\)\s+\(/) { - print "Whitespace between ')' and '(':\n$$location"; + if ($data =~ /\(\*\w+\)\s+\(/) { + print "Whitespace between ')' and '(':\n"; + print "$file:$.:\n$line"; $ret = 1; } # Forbid whitespace following ( or prior to ) # but allow whitespace before ) on a single line # (optionally followed by a semicolon) - if (($$data =~ /\s\)/ && not $$data =~ /^\s+\);?$/) || - $$data =~ /\((?!$)\s/) { - print "Whitespace after '(' or before ')':\n$$location"; + if (($data =~ /\s\)/ && not $data =~ /^\s+\);?$/) || + $data =~ /\((?!$)\s/) { + print "Whitespace after '(' or before ')':\n"; + print "$file:$.:\n$line"; $ret = 1; } @@ -171,35 +175,37 @@ sub CheckWhiteSpaces { # errno == EINTR) # ; # - if ($$data =~ /\s[;,]/) { - unless ($$data =~ /\S; ; / || - $$data =~ /^\s+;/) { - print "Whitespace before semicolon or comma:\n$$location"; + if ($data =~ /\s[;,]/) { + unless ($data =~ /\S; ; / || + $data =~ /^\s+;/) { + print "Whitespace before semicolon or comma:\n"; + print "$file:$.:\n$line"; $ret = 1; } } # Require EOL, macro line continuation, or whitespace after ";". # Allow "for (;;)" as an exception. - if ($$data =~ /;[^ \\\n;)]/) { - print "Invalid character after semicolon:\n$$location"; + if ($data =~ /;[^ \\\n;)]/) { + print "Invalid character after semicolon:\n"; + print "$file:$.:\n$line"; $ret = 1; } # Require EOL, space, or enum/struct end after comma. - if ($$data =~ /,[^ \\\n)}]/) { - print "Invalid character after comma:\n$$location"; + if ($data =~ /,[^ \\\n)}]/) { + print "Invalid character after comma:\n"; + print "$file:$.:\n$line"; $ret = 1; } # Require spaces around assignment '=', compounds and '==' - if ($$data =~ /[^ ]\b[!<>&|\-+*\/%\^=]?=/ || - $$data =~ /=[^= \\\n]/) { - print "Spacing around '=' or '==':\n$$location"; + if ($data =~ /[^ ]\b[!<>&|\-+*\/%\^=]?=/ || + $data =~ /=[^= \\\n]/) { + print "Spacing around '=' or '==':\n"; + print "$file:$.:\n$line"; $ret = 1; } - - return $ret; } # @@ -210,46 +216,43 @@ sub CheckWhiteSpaces { # $_[3]: $cb_linenum(inout) # $_[4]: $cb_code(inout) # $_[5]: $cb_scolon(inout) -# Returns 0 in case of success or 1 on failure +# Set $ret 1 on failure # # Check whitespaces according to code spec of libvirt. # sub CheckCurlyBrackets { - my $ret = 0; - my ($data, $file, $line, $cb_linenum, $cb_code, $cb_scolon) = @_; + our ($data, $file, $line, $cb_linenum, $cb_code, $cb_scolon); # One line conditional statements with one line bodies should # not use curly brackets. - if ($$data =~ /^\s*(if|while|for)\b.*\{$/) { - $$cb_linenum = $.; - $$cb_code = $$line; - $$cb_scolon = 0; + if ($data =~ /^\s*(if|while|for)\b.*\{$/) { + $cb_linenum = $.; + $cb_code = $line; + $cb_scolon = 0; } # We need to check for exactly one semicolon inside the body, # because empty statements (e.g. with comment only) are # allowed - if ($$cb_linenum == $. - 1 && $$data =~ /^[^;]*;[^;]*$/) { - $$cb_code .= $$line; - $$cb_scolon = 1; + if ($cb_linenum == $. - 1 && $data =~ /^[^;]*;[^;]*$/) { + $cb_code .= $line; + $cb_scolon = 1; } - if ($$data =~ /^\s*}\s*$/ && - $$cb_linenum == $. - 2 && - $$cb_scolon) { + if ($data =~ /^\s*}\s*$/ && + $cb_linenum == $. - 2 && + $cb_scolon) { print "Curly brackets around single-line body:\n"; - print "$$file:$$cb_linenum-$.:\n$$cb_code$$line"; + print "$file:$cb_linenum-$.:\n$cb_code$line"; $ret = 1; # There _should_ be no need to reset the values; but to # keep my inner peace... - $$cb_linenum = 0; - $$cb_scolon = 0; - $$cb_code = ""; + $cb_linenum = 0; + $cb_scolon = 0; + $cb_code = ""; } - - return $ret; } # @@ -259,22 +262,21 @@ sub CheckCurlyBrackets { # $_[2]: $line(in) # $_[3]: @paren_stack(inout), which maintains information # of the parenthesis -# Returns 0 in case of success or 1 on failure +# Set $ret 1 on failure # # Check misaligned stuff in parenthesis: # 1. For misaligned arguments of function # 2. For misaligned conditions of [if|while|switch|...] # sub CheckMisalignment { - my $ret = 0; - my ($data, $file, $line, $paren_stack) = @_; + our ($data, $file, $line, @paren_stack); # Check alignment based on @paren_stack - if (@$paren_stack) { - if ($$data =~ /(\S+.*$)/) { - my $pos = $$paren_stack[-1][0]; - my $linenum = $$paren_stack[-1][1]; - my $code = $$paren_stack[-1][2]; + if (@paren_stack) { + if ($data =~ /(\S+.*$)/) { + my $pos = $paren_stack[-1][0]; + my $linenum = $paren_stack[-1][1]; + my $code = $paren_stack[-1][2]; if ($pos != length($`)) { my $pad = ""; my $indicator = ""; @@ -282,7 +284,7 @@ sub CheckMisalignment { $pad = " " x $pos . "...\n"; } print "Misaligned line in parenthesis:\n"; - print "$$file:$linenum-$.:\n$code$pad$$line"; + print "$file:$linenum-$.:\n$code$pad$line"; if ($pos > length($`)) { $indicator = " " x length($`); $indicator .= "~" x ($pos - length($`)); @@ -299,9 +301,9 @@ sub CheckMisalignment { } # Maintain @paren_stack - if ($$data =~ /.*[()]/) { + if ($data =~ /.*[()]/) { my $pos = 0; - my $temp = $$data; + my $temp = $data; $temp =~ s/\s+$//; # Kill the content between matched parenthesis and themselves @@ -310,12 +312,12 @@ sub CheckMisalignment { # Pop a item for the open-paren when finding close-paren while (($pos = index($temp, "\)", $pos)) >= 0) { - if (@$paren_stack) { - pop(@$paren_stack); + if (@paren_stack) { + pop(@paren_stack); $pos++; } else { print "Warning: found unbalanced parenthesis:\n"; - print "$$file:$.:\n$$line\n"; + print "$file:$.:\n$line\n"; $ret = 1; last; } @@ -330,36 +332,31 @@ sub CheckMisalignment { $correct = ($correct >= $recent) ? $correct : $recent; $correct += 4 - ($correct % 4); if ($correct < $pos) { - push @$paren_stack, [$correct, $., $$line]; + push @paren_stack, [$correct, $., $line]; last; } } - push @$paren_stack, [$pos+1, $., $$line]; + push @paren_stack, [$pos+1, $., $line]; $pos++; } } - - return $ret; } -my $ret = 0; - -foreach my $file (@ARGV) { +foreach our $file (@ARGV) { # Per-file variables for multiline Curly Bracket (cb_) check - my $cb_linenum = 0; - my $cb_code = ""; - my $cb_scolon = 0; - my $fn_linenum = 0; - my $incomment = 0; - my @paren_stack; + our $cb_linenum = 0; + our $cb_code = ""; + our $cb_scolon = 0; + our $fn_linenum = 0; + our $incomment = 0; + our @paren_stack = (); open FILE, $file; - while (defined (my $line = <FILE>)) { - my $has_define = 0; - my $data = $line; - my $location = "$file:$.:\n$line"; + while (defined (our $line = <FILE>)) { + our $has_define = 0; + our $data = $line; # Kill any quoted , ; = or " $data =~ s/'[";,=]'/'X'/g; @@ -376,14 +373,13 @@ foreach my $file (@ARGV) { # Ignore all macros except for #define next if $data =~ /^#/; - $ret = 1 if CheckFunctionBody(\$data, \$location, \$fn_linenum); + CheckFunctionBody(); - KillComments(\$data, \$incomment); + KillComments(); - $ret = 1 if CheckWhiteSpaces(\$data, \$location); + CheckWhiteSpaces(); - $ret = 1 if CheckCurlyBrackets(\$data, \$file, \$line, - \$cb_linenum, \$cb_code, \$cb_scolon); + CheckCurlyBrackets(); } ##################################################################### @@ -395,7 +391,7 @@ foreach my $file (@ARGV) { ##################################################################### next unless $file =~ /^src\/(?!esx|qemu|hyperv|lxc|conf|libxl|vbox|test|security)/; - $ret = 1 if CheckMisalignment(\$data, \$file, \$line, \@paren_stack); + CheckMisalignment(); } close FILE; } -- 2.17.1

On Fri, Oct 05, 2018 at 04:11:45PM +0800, Shi Lei wrote:
This patch replaces those 'my varname;' with 'our varname;', i.e. it uses global var, rather than passing arguments to subroutine. So it can be a bit faster.
NACK Use of global variables like this is harmful to maintenance of the code. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Fri, Oct 05, 2018 at 09:26:22AM +0100, Daniel P. Berrangé wrote:
On Fri, Oct 05, 2018 at 04:11:45PM +0800, Shi Lei wrote:
This patch replaces those 'my varname;' with 'our varname;', i.e. it uses global var, rather than passing arguments to subroutine. So it can be a bit faster.
NACK
Use of global variables like this is harmful to maintenance of the code.
Also, it does not really speed up the script. Given that most of the slowdown happened by separating the code into subroutines, I suspect that the regexes are no longer cached. Jano
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Fri, Oct 05, 2018 at 04:11:23PM +0800, Shi Lei wrote:
This series is batch(II) and it continues to fix misaligned arguments and misaligned conditions in src directory. The batch I: https://www.redhat.com/archives/libvir-list/2018-September/msg00888.html In addition to fix misaligned stuff, this series includes several other jobs:
I was away when that series merged, but I'm not at all a fan of writing our own custom code for checking indentation. IMHO we should be just picking an existing tool such as either ident or clang-format, and providing a desired config for it. I've looked at clang-format before and it is pretty good. It does not have ability to quite match our code style, but I don't think that is a real show stopper. We'd be better off just adapting to one of the common code styles rather than inventing yet another app todo code indent analysis. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Fri, 2018-10-05 at 09:31 +0100, Daniel P. Berrangé wrote:
I've looked at clang-format before and it is pretty good. It does not have ability to quite match our code style, but I don't think that is a real show stopper. We'd be better off just adapting to one of the common code styles rather than inventing yet another app todo code indent analysis.
I *strongly* support this idea :) -- Andrea Bolognani / Red Hat / Virtualization

On Fri, Oct 05, 2018 at 11:11:28AM +0200, Andrea Bolognani wrote:
On Fri, 2018-10-05 at 09:31 +0100, Daniel P. Berrangé wrote:
I've looked at clang-format before and it is pretty good. It does not have ability to quite match our code style, but I don't think that is a real show stopper. We'd be better off just adapting to one of the common code styles rather than inventing yet another app todo code indent analysis.
I *strongly* support this idea :)
The other benefit of clang-format is that it can actually fix the code automatically, as well as reporting on the problem. Our syntax check tool merely reports the problem leaving the developer tedious work to fix each problem. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 2018-10-05 at 17:16, DanielP. Berrangé wrote:
On Fri, Oct 05, 2018 at 11:11:28AM +0200, Andrea Bolognani wrote:
On Fri, 2018-10-05 at 09:31 +0100, Daniel P. Berrangé wrote:
I've looked at clang-format before and it is pretty good. It does not have ability to quite match our code style, but I don't think that is a real show stopper. We'd be better off just adapting to one of the common code styles rather than inventing yet another app todo code indent analysis.
I *strongly* support this idea :)
The other benefit of clang-format is that it can actually fix the code automatically, as well as reporting on the problem. Our syntax check tool merely reports the problem leaving the developer tedious work to fix each problem.
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Don't know that before. Thanks! The clang-format is really good and its style could be customized according to libvirt. Shi Lei
participants (4)
-
Andrea Bolognani
-
Daniel P. Berrangé
-
Ján Tomko
-
Shi Lei