From nobody Thu May 2 20:27:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537346330838868.4900561470679; Wed, 19 Sep 2018 01:38:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3596F308A967; Wed, 19 Sep 2018 08:38:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1C9889F4D; Wed, 19 Sep 2018 08:38:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AAF24181A71F; Wed, 19 Sep 2018 08:38:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8J8cXOU006646 for ; Wed, 19 Sep 2018 04:38:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7971E830EB; Wed, 19 Sep 2018 08:38:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70D1982AF8 for ; Wed, 19 Sep 2018 08:38:30 +0000 (UTC) Received: from m97135.mail.qiye.163.com (m97135.mail.qiye.163.com [220.181.97.135]) by mx1.redhat.com (Postfix) with ESMTP id DA7F0750D0 for ; Wed, 19 Sep 2018 08:38:26 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp1 (Coremail) with SMTP id h+CowACH6K8AC6Jb9vM3Ag--.63S3; Wed, 19 Sep 2018 16:38:24 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 19 Sep 2018 16:38:14 +0800 Message-Id: <20180919083819.11042-2-shi_lei@massclouds.com> In-Reply-To: <20180919083819.11042-1-shi_lei@massclouds.com> References: <20180919083819.11042-1-shi_lei@massclouds.com> X-CM-TRANSID: h+CowACH6K8AC6Jb9vM3Ag--.63S3 X-Coremail-Antispam: 1Uf129KBjvAXoWfXr4rtF4UWw45KrWkKw4Durg_yoWrXF47Wo W3JF42kw1Uuw18ZFs8t347GrW3ZFy8K3yrXrsYqFWq9ayxWry5Wry8Cr13KrZ5Xr1fGFs7 C3W2q3y5Grn3Grn3n29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTR_BMKDUUUU X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbieQHGT1qrhQkfaAAAs7 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 19 Sep 2018 08:38:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 19 Sep 2018 08:38:28 +0000 (UTC) for IP:'220.181.97.135' DOMAIN:'m97135.mail.qiye.163.com' HELO:'m97135.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 220.181.97.135 m97135.mail.qiye.163.com 220.181.97.135 m97135.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] util: Fix misaligned arguments and misaligned conditions for [if|while|...] X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 19 Sep 2018 08:38:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch just fixes misaligned arguments and misaligned conditions of src/util/*.c. Signed-off-by: Shi Lei --- src/util/vircgroup.c | 34 +++++++++--------- src/util/virconf.c | 4 +-- src/util/virdbus.c | 2 +- src/util/virdnsmasq.c | 5 +-- src/util/virerror.c | 2 +- src/util/virevent.c | 14 ++++---- src/util/vireventpoll.c | 8 ++--- src/util/virfile.c | 6 ++-- src/util/virgic.c | 2 +- src/util/virhook.c | 2 +- src/util/virhostdev.c | 23 ++++++------ src/util/viridentity.c | 18 +++++----- src/util/viriscsi.c | 22 ++++++------ src/util/virjson.c | 2 +- src/util/virkeycode.c | 22 ++++++------ src/util/virkeyfile.c | 6 ++-- src/util/virlockspace.c | 2 +- src/util/virlog.c | 18 +++++----- src/util/virnetdev.c | 4 +-- src/util/virnetdevbridge.c | 2 +- src/util/virnetdevip.c | 11 +++--- src/util/virnetdevmacvlan.c | 30 ++++++++-------- src/util/virnetdevopenvswitch.c | 34 +++++++++--------- src/util/virnetdevvportprofile.c | 24 ++++++------- src/util/virnetlink.c | 10 +++--- src/util/virobject.c | 2 +- src/util/virpci.c | 4 +-- src/util/virperf.c | 4 +-- src/util/virprocess.c | 2 +- src/util/virqemu.c | 4 +-- src/util/virresctrl.c | 7 ++-- src/util/virsocketaddr.c | 2 +- src/util/virstorageencryption.c | 2 +- src/util/virstoragefile.c | 60 ++++++++++++++------------------ src/util/virsysinfo.c | 2 +- src/util/viruri.c | 2 +- src/util/virutil.c | 2 +- src/util/virxml.c | 2 +- 38 files changed, 197 insertions(+), 205 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 64507bf..ab5ff6d 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -2066,9 +2066,9 @@ virCgroupSetBlkioDeviceReadIops(virCgroupPtr group, return -1; =20 return virCgroupSetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.read_iops_device", - str); + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.throttle.read_iops_device", + str); } =20 =20 @@ -2095,9 +2095,9 @@ virCgroupSetBlkioDeviceWriteIops(virCgroupPtr group, return -1; =20 return virCgroupSetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.write_iops_device", - str); + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.throttle.write_iops_device", + str); } =20 =20 @@ -2124,9 +2124,9 @@ virCgroupSetBlkioDeviceReadBps(virCgroupPtr group, return -1; =20 return virCgroupSetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.read_bps_device", - str); + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.throttle.read_bps_device", + str); } =20 /** @@ -2152,9 +2152,9 @@ virCgroupSetBlkioDeviceWriteBps(virCgroupPtr group, return -1; =20 return virCgroupSetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.write_bps_device", - str); + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.throttle.write_bps_device", + str); } =20 =20 @@ -2182,9 +2182,9 @@ virCgroupSetBlkioDeviceWeight(virCgroupPtr group, return -1; =20 return virCgroupSetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.weight_device", - str); + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.weight_device", + str); } =20 /** @@ -3218,8 +3218,8 @@ virCgroupGetPercpuStats(virCgroupPtr group, goto cleanup; =20 for (i =3D start_cpu; i < need_cpus; i++) { - if (virTypedParameterAssign(¶ms[(i - start_cpu) * nparams + - param_idx], + int idx =3D (i - start_cpu) * nparams + param_idx; + if (virTypedParameterAssign(¶ms[idx], VIR_DOMAIN_CPU_STATS_VCPUTIME, VIR_TYPED_PARAM_ULLONG, sum_cpu_time[i]) < 0) diff --git a/src/util/virconf.c b/src/util/virconf.c index e0a3fd1..217ca89 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -463,7 +463,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt) return NULL; } if ((CUR =3D=3D '"') || (CUR =3D=3D '\'') || - (ctxt->conf->flags & VIR_CONF_FLAG_LXC_FORMAT)) { + (ctxt->conf->flags & VIR_CONF_FLAG_LXC_FORMAT)) { type =3D VIR_CONF_STRING; str =3D virConfParseString(ctxt); if (str =3D=3D NULL) @@ -1428,7 +1428,7 @@ int virConfWalk(virConfPtr conf, cur =3D conf->entries; while (cur !=3D NULL) { if (cur->name && cur->value && - callback(cur->name, cur->value, opaque) < 0) + callback(cur->name, cur->value, opaque) < 0) return -1; cur =3D cur->next; } diff --git a/src/util/virdbus.c b/src/util/virdbus.c index ba8b684..05b1f6c 100644 --- a/src/util/virdbus.c +++ b/src/util/virdbus.c @@ -1567,7 +1567,7 @@ virDBusCall(DBusConnection *conn, ret =3D 0; } else { virReportError(VIR_ERR_DBUS_SERVICE, _("%s: %s"), member, - localerror.message ? localerror.message : _("unknown error= ")); + localerror.message ? : _("unknown error")); } goto cleanup; } diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 7872b6e..50f40c8 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -605,8 +605,9 @@ dnsmasqReload(pid_t pid ATTRIBUTE_UNUSED) #ifndef WIN32 if (kill(pid, SIGHUP) !=3D 0) { virReportSystemError(errno, - _("Failed to make dnsmasq (PID: %d) reload config files."), - pid); + _("Failed to make dnsmasq (PID: %d)" + " reload config files."), + pid); return -1; } #endif /* WIN32 */ diff --git a/src/util/virerror.c b/src/util/virerror.c index 4688e01..a796035 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -139,7 +139,7 @@ VIR_ENUM_IMPL(virErrorDomain, VIR_ERR_DOMAIN_LAST, "Perf", /* 65 */ "Libssh transport layer", "Resource control", - ) + ) =20 =20 /* diff --git a/src/util/virevent.c b/src/util/virevent.c index 87069e3..8211348 100644 --- a/src/util/virevent.c +++ b/src/util/virevent.c @@ -286,14 +286,12 @@ int virEventRegisterDefaultImpl(void) return -1; } =20 - virEventRegisterImpl( - virEventPollAddHandle, - virEventPollUpdateHandle, - virEventPollRemoveHandle, - virEventPollAddTimeout, - virEventPollUpdateTimeout, - virEventPollRemoveTimeout - ); + virEventRegisterImpl(virEventPollAddHandle, + virEventPollUpdateHandle, + virEventPollRemoveHandle, + virEventPollAddTimeout, + virEventPollUpdateTimeout, + virEventPollRemoveTimeout); =20 return 0; } diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c index 2fe58c7..ebe7e5c 100644 --- a/src/util/vireventpoll.c +++ b/src/util/vireventpoll.c @@ -545,10 +545,10 @@ static void virEventPollCleanupTimeouts(void) } =20 if ((i+1) < eventLoop.timeoutsCount) { + size_t count =3D eventLoop.timeoutsCount - (i+1); memmove(eventLoop.timeouts+i, eventLoop.timeouts+i+1, - sizeof(struct virEventPollTimeout)*(eventLoop.timeouts= Count - -(i+1))); + sizeof(struct virEventPollTimeout)*count); } eventLoop.timeoutsCount--; } @@ -594,10 +594,10 @@ static void virEventPollCleanupHandles(void) } =20 if ((i+1) < eventLoop.handlesCount) { + size_t count =3D eventLoop.handlesCount - (i+1); memmove(eventLoop.handles+i, eventLoop.handles+i+1, - sizeof(struct virEventPollHandle)*(eventLoop.handlesCo= unt - -(i+1))); + sizeof(struct virEventPollHandle)*count); } eventLoop.handlesCount--; } diff --git a/src/util/virfile.c b/src/util/virfile.c index af45a51..34d3213 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -304,7 +304,7 @@ virFileWrapperFdNew(int *fd ATTRIBUTE_UNUSED, unsigned int fdflags ATTRIBUTE_UNUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("virFileWrapperFd unsupported on this platform")); + _("virFileWrapperFd unsupported on this platform")); return NULL; } #endif @@ -658,7 +658,7 @@ static int virFileLoopDeviceOpenLoopCtl(char **dev_name= , int *fd) =20 if ((*fd =3D open(looppath, O_RDWR)) < 0) { virReportSystemError(errno, - _("Unable to open %s"), looppath); + _("Unable to open %s"), looppath); VIR_FREE(looppath); return -1; } @@ -3484,7 +3484,7 @@ virFileIsSharedFSType(const char *path, =20 if ((p =3D strrchr(dirpath, '/')) =3D=3D NULL) { virReportSystemError(EINVAL, - _("Invalid relative path '%s'"), path); + _("Invalid relative path '%s'"), path); return -1; } =20 diff --git a/src/util/virgic.c b/src/util/virgic.c index e7326d6..6f26659 100644 --- a/src/util/virgic.c +++ b/src/util/virgic.c @@ -30,4 +30,4 @@ VIR_ENUM_IMPL(virGICVersion, VIR_GIC_VERSION_LAST, "host", "2", "3", -); + ); diff --git a/src/util/virhook.c b/src/util/virhook.c index 993f06d..431222b 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -251,7 +251,7 @@ virHookCall(int driver, if ((virHooksFound =3D=3D -1) || ((driver =3D=3D VIR_HOOK_DRIVER_DAEMON) && (op =3D=3D VIR_HOOK_DAEMON_OP_RELOAD || - op =3D=3D VIR_HOOK_DAEMON_OP_SHUTDOWN))) + op =3D=3D VIR_HOOK_DAEMON_OP_SHUTDOWN))) virHookInitialize(); =20 if ((virHooksFound & (1 << driver)) =3D=3D 0) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index ca79c37..b3278a8 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -322,7 +322,7 @@ virHostdevNetDevice(virDomainHostdevDefPtr hostdev, if (!linkdev) { virReportError(VIR_ERR_INTERNAL_ERROR, _("The device at %s has no network device name"= ), - sysfs_path); + sysfs_path); return -1; } =20 @@ -540,13 +540,12 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr hos= tdev, if (virHostdevNetDevice(hostdev, 0, &linkdev, &vf) < 0) return -1; =20 - virtPort =3D virDomainNetGetActualVirtPortProfile( - hostdev->parent.data.net); + virtPort =3D virDomainNetGetActualVirtPortProfile(hostdev->parent.data= .net); if (virtPort) { return virHostdevNetConfigVirtPortProfile(linkdev, vf, virtPort, - &hostdev->parent.data.net= ->mac, - NULL, - port_profile_associate); + &hostdev->parent.data.ne= t->mac, + NULL, + port_profile_associate); } else { /* we need to try 3 different places for the config file: * 1) ${stateDir}/${PF}_vf${vf} @@ -770,7 +769,7 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, } else { virReportError(VIR_ERR_OPERATION_INVALID, _("Unmanaged PCI device %s must be manually= " - "detached from the host"), + "detached from the host"), virPCIDeviceGetName(pci)); goto reattachdevs; } @@ -1920,8 +1919,8 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPt= r mgr, } =20 VIR_DEBUG("Removing %s:%u:%u:%llu dom=3D%s from activeSCSIHostdevs", - scsihostsrc->adapter, scsihostsrc->bus, scsihostsrc->target, - scsihostsrc->unit, dom_name); + scsihostsrc->adapter, scsihostsrc->bus, scsihostsrc->target, + scsihostsrc->unit, dom_name); =20 virSCSIDeviceListDel(mgr->activeSCSIHostdevs, tmp, drv_name, dom_name); @@ -2008,7 +2007,7 @@ virHostdevReAttachSCSIVHostDevices(virHostdevManagerP= tr mgr, if (STREQ_NULLABLE(drv_name, usedby_drvname) && STREQ_NULLABLE(dom_name, usedby_domname)) { VIR_DEBUG("Removing %s dom=3D%s from activeSCSIVHostHostdevs", - hostsrc->wwpn, dom_name); + hostsrc->wwpn, dom_name); =20 virSCSIVHostDeviceListDel(mgr->activeSCSIVHostHostdevs, tmp); } @@ -2173,8 +2172,8 @@ virHostdevPrepareDomainDevices(virHostdevManagerPtr m= gr, =20 if (flags & VIR_HOSTDEV_SP_USB) { if (virHostdevPrepareUSBDevices(mgr, driver, def->name, - def->hostdevs, def->nhostdevs, - flags) < 0) + def->hostdevs, def->nhostdevs, + flags) < 0) return -1; } =20 diff --git a/src/util/viridentity.c b/src/util/viridentity.c index c621444..e7637b5 100644 --- a/src/util/viridentity.c +++ b/src/util/viridentity.c @@ -242,7 +242,7 @@ int virIdentitySetAttr(virIdentityPtr ident, =20 if (ident->attrs[attr]) { virReportError(VIR_ERR_OPERATION_DENIED, "%s", - _("Identity attribute is already set")); + _("Identity attribute is already set")); goto cleanup; } =20 @@ -463,8 +463,8 @@ int virIdentitySetUNIXUserID(virIdentityPtr ident, return -1; =20 return virIdentitySetAttr(ident, - VIR_IDENTITY_ATTR_UNIX_USER_ID, - val); + VIR_IDENTITY_ATTR_UNIX_USER_ID, + val); } =20 =20 @@ -486,8 +486,8 @@ int virIdentitySetUNIXGroupID(virIdentityPtr ident, return -1; =20 return virIdentitySetAttr(ident, - VIR_IDENTITY_ATTR_UNIX_GROUP_ID, - val); + VIR_IDENTITY_ATTR_UNIX_GROUP_ID, + val); } =20 =20 @@ -500,8 +500,8 @@ int virIdentitySetUNIXProcessID(virIdentityPtr ident, return -1; =20 return virIdentitySetAttr(ident, - VIR_IDENTITY_ATTR_UNIX_PROCESS_ID, - val); + VIR_IDENTITY_ATTR_UNIX_PROCESS_ID, + val); } =20 =20 @@ -514,8 +514,8 @@ int virIdentitySetUNIXProcessTime(virIdentityPtr ident, return -1; =20 return virIdentitySetAttr(ident, - VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME, - val); + VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME, + val); } =20 =20 diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index 0fcedc8..f8345c7 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -92,7 +92,7 @@ virISCSIGetSession(const char *devpath, VIR_AUTOFREE(char *) error =3D NULL; =20 VIR_AUTOPTR(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, "--mode= ", - "session", NULL); + "session", NULL); virCommandSetErrorBuffer(cmd, &error); =20 if (virCommandRunRegex(cmd, @@ -127,7 +127,7 @@ virStorageBackendIQNFound(const char *initiatoriqn, VIR_AUTOFREE(char *) iface =3D NULL; VIR_AUTOFREE(char *) iqn =3D NULL; VIR_AUTOPTR(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, - "--mode", "iface", NULL); + "--mode", "iface", = NULL); =20 *ifacename =3D NULL; =20 @@ -351,10 +351,10 @@ int virISCSIRescanLUNs(const char *session) { VIR_AUTOPTR(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, - "--mode", "session", - "-r", session, - "-R", - NULL); + "--mode", "session", + "-r", session, + "-R", + NULL); return virCommandRun(cmd, NULL); } =20 @@ -406,10 +406,10 @@ virISCSIScanTargetsInternal(const char *portal, struct virISCSITargetList list; size_t i; VIR_AUTOPTR(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, - "--mode", "discovery", - "--type", "sendtargets", - "--portal", portal, - NULL); + "--mode", "discover= y", + "--type", "sendtarg= ets", + "--portal", portal, + NULL); =20 if (!persist) { virCommandAddArgList(cmd, @@ -496,7 +496,7 @@ virISCSIScanTargets(const char *portal, } =20 return virISCSIScanTargetsInternal(portal, ifacename, - persist, ntargets, targets); + persist, ntargets, targets); } =20 =20 diff --git a/src/util/virjson.c b/src/util/virjson.c index 0f16086..78f868a 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1898,7 +1898,7 @@ virJSONValueToStringOne(virJSONValuePtr object, if (yajl_gen_string(g, (unsigned char *)object->data.object.pairs= [i].key, strlen(object->data.object.pairs[i].key)) - !=3D yajl_gen_status_ok) + !=3D yajl_gen_status_ok) return -1; if (virJSONValueToStringOne(object->data.object.pairs[i].value= , g) < 0) return -1; diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c index 8976bbf..1135872 100644 --- a/src/util/virkeycode.c +++ b/src/util/virkeycode.c @@ -70,17 +70,17 @@ verify(VIR_KEYMAP_ENTRY_MAX =3D=3D ARRAY_CARDINALITY(vi= rKeyNameTable_osx)); verify(VIR_KEYMAP_ENTRY_MAX =3D=3D ARRAY_CARDINALITY(virKeyNameTable_win32= )); =20 VIR_ENUM_IMPL(virKeycodeSet, VIR_KEYCODE_SET_LAST, - "linux", - "xt", - "atset1", - "atset2", - "atset3", - "os_x", - "xt_kbd", - "usb", - "win32", - "qnum", -); + "linux", + "xt", + "atset1", + "atset2", + "atset3", + "os_x", + "xt_kbd", + "usb", + "win32", + "qnum", + ); =20 int virKeycodeValueFromString(virKeycodeSet codeset, const char *keyname) diff --git a/src/util/virkeyfile.c b/src/util/virkeyfile.c index da06425..88ae2a5 100644 --- a/src/util/virkeyfile.c +++ b/src/util/virkeyfile.c @@ -334,7 +334,7 @@ void virKeyFileFree(virKeyFilePtr conf) =20 =20 bool virKeyFileHasGroup(virKeyFilePtr conf, - const char *groupname) + const char *groupname) { VIR_DEBUG("conf=3D%p groupname=3D%s", conf, groupname); return virHashLookup(conf->groups, groupname) !=3D NULL; @@ -342,8 +342,8 @@ bool virKeyFileHasGroup(virKeyFilePtr conf, =20 =20 bool virKeyFileHasValue(virKeyFilePtr conf, - const char *groupname, - const char *valuename) + const char *groupname, + const char *valuename) { virHashTablePtr group =3D virHashLookup(conf->groups, groupname); VIR_DEBUG("conf=3D%p groupname=3D%s valuename=3D%s", conf, groupname, = valuename); diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 60bfef4..79fa48d 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -269,7 +269,7 @@ virLockSpacePtr virLockSpaceNew(const char *directory) if (!virFileIsDir(directory)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Lockspace location %s exists, but is not= a directory"), - directory); + directory); goto error; } } else { diff --git a/src/util/virlog.c b/src/util/virlog.c index 64c0efc..17f25dd 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -634,23 +634,23 @@ virLogVMessage(virLogSourcePtr source, char *initmsg =3D NULL; if (virLogVersionString(&rawinitmsg, &initmsg) >=3D 0) virLogOutputs[i]->f(&virLogSelf, VIR_LOG_INFO, - __FILE__, __LINE__, __func__, - timestamp, NULL, 0, rawinitmsg, ini= tmsg, - virLogOutputs[i]->data); + __FILE__, __LINE__, __func__, + timestamp, NULL, 0, rawinitmsg, in= itmsg, + virLogOutputs[i]->data); VIR_FREE(initmsg); if (virLogHostnameString(&hoststr, &initmsg) >=3D 0) virLogOutputs[i]->f(&virLogSelf, VIR_LOG_INFO, - __FILE__, __LINE__, __func__, - timestamp, NULL, 0, hoststr, initms= g, - virLogOutputs[i]->data); + __FILE__, __LINE__, __func__, + timestamp, NULL, 0, hoststr, initm= sg, + virLogOutputs[i]->data); VIR_FREE(hoststr); VIR_FREE(initmsg); virLogOutputs[i]->logInitMessage =3D false; } virLogOutputs[i]->f(source, priority, - filename, linenr, funcname, - timestamp, metadata, filterflags, - str, msg, virLogOutputs[i]->data); + filename, linenr, funcname, + timestamp, metadata, filterflags, + str, msg, virLogOutputs[i]->data); } } if (virLogNbOutputs =3D=3D 0) { diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 39c9131..dde9ced 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1079,7 +1079,7 @@ virNetDevSysfsFile(char **pf_sysfs_device_link, const= char *ifname, =20 static int virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, const char *ifname, - const char *file) + const char *file) { if (virAsprintf(pf_sysfs_device_link, SYSFS_NET_DIR "%s/device/%s", if= name, file) < 0) @@ -2717,7 +2717,7 @@ static int virNetDevParseMcast(char *buf, virNetDevMc= astEntryPtr mcast) break; case VIR_MCAST_TYPE_ADDR_TOKEN: if (virMacAddrParseHex((const char*)token, - &mcast->macaddr) < 0) { + &mcast->macaddr) < 0) { virReportSystemError(EINVAL, _("Failed to parse MAC address fr= om '%s'"), buf); diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index e02d1ad..071ebb7 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -642,7 +642,7 @@ int virNetDevBridgeRemovePort(const char *brname, } #elif defined(HAVE_BSD_BRIDGE_MGMT) int virNetDevBridgeRemovePort(const char *brname, - const char *ifname) + const char *ifname) { struct ifbreq req; =20 diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index 103ff9e..9f940e1 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -404,7 +404,7 @@ virNetDevIPParseDadStatus(struct nlmsghdr *nlh, int len, VIR_WARNINGS_NO_CAST_ALIGN rtattr_ptr =3D (struct rtattr *) IFA_RTA(ifaddrmsg_ptr); for (; RTA_OK(rtattr_ptr, ifaddrmsg_len); - rtattr_ptr =3D RTA_NEXT(rtattr_ptr, ifaddrmsg_len)) { + rtattr_ptr =3D RTA_NEXT(rtattr_ptr, ifaddrmsg_len)) { VIR_WARNINGS_RESET if (RTA_PAYLOAD(rtattr_ptr) !=3D sizeof(struct in6_addr)) { /* No address: ignore. */ @@ -660,9 +660,10 @@ virNetDevIPAddrAdd(const char *ifname, return -1; =20 /* format up a broadcast address if this is IPv4 */ - if (!peerstr && ((VIR_SOCKET_ADDR_IS_FAMILY(addr, AF_INET)) && - ((virSocketAddrBroadcastByPrefix(addr, prefix, &broadcast) < 0) || - !(bcaststr =3D virSocketAddrFormat(&broadcast))))) { + if (!peerstr && + ((VIR_SOCKET_ADDR_IS_FAMILY(addr, AF_INET)) && + ((virSocketAddrBroadcastByPrefix(addr, prefix, &broadcast) < 0) || + !(bcaststr =3D virSocketAddrFormat(&broadcast))))) { return -1; } =20 @@ -749,7 +750,7 @@ virNetDevIPRouteAdd(const char *ifname, virCommandAddArgList(cmd, "route", "add", NULL); virCommandAddArgFormat(cmd, "%s/%u", addrstr, prefix); virCommandAddArgList(cmd, "via", gatewaystr, "dev", ifname, - "proto", "static", "metric", NULL); + "proto", "static", "metric", NULL); virCommandAddArgFormat(cmd, "%u", metric); =20 if (virCommandRun(cmd, NULL) < 0) diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index a6b726f..0a9abbf 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -602,25 +602,25 @@ virNetDevMacVLanVPortProfileCallback(struct nlmsghdr = *hdr, case RTM_GETLINK: VIR_DEBUG(" IFINFOMSG"); VIR_DEBUG(" ifi_family =3D 0x%02x", - ((struct ifinfomsg *)data)->ifi_family); + ((struct ifinfomsg *)data)->ifi_family); VIR_DEBUG(" ifi_type =3D 0x%x", - ((struct ifinfomsg *)data)->ifi_type); + ((struct ifinfomsg *)data)->ifi_type); VIR_DEBUG(" ifi_index =3D %i", - ((struct ifinfomsg *)data)->ifi_index); + ((struct ifinfomsg *)data)->ifi_index); VIR_DEBUG(" ifi_flags =3D 0x%04x", - ((struct ifinfomsg *)data)->ifi_flags); + ((struct ifinfomsg *)data)->ifi_flags); VIR_DEBUG(" ifi_change =3D 0x%04x", - ((struct ifinfomsg *)data)->ifi_change); + ((struct ifinfomsg *)data)->ifi_change); } /* DEBUG end */ =20 /* Parse netlink message assume a setlink with vfports */ memcpy(&ifinfo, NLMSG_DATA(hdr), sizeof(ifinfo)); VIR_DEBUG("family:%#x type:%#x index:%d flags:%#x change:%#x", - ifinfo.ifi_family, ifinfo.ifi_type, ifinfo.ifi_index, - ifinfo.ifi_flags, ifinfo.ifi_change); + ifinfo.ifi_family, ifinfo.ifi_type, ifinfo.ifi_index, + ifinfo.ifi_flags, ifinfo.ifi_change); if (nlmsg_parse(hdr, sizeof(ifinfo), - (struct nlattr **)&tb, IFLA_MAX, NULL)) { + (struct nlattr **)&tb, IFLA_MAX, NULL)) { VIR_DEBUG("error parsing request..."); return; } @@ -631,13 +631,13 @@ virNetDevMacVLanVPortProfileCallback(struct nlmsghdr = *hdr, nla_for_each_nested(tb_vfinfo_list, tb[IFLA_VFINFO_LIST], rem) { if (nla_type(tb_vfinfo_list) !=3D IFLA_VF_INFO) { VIR_DEBUG("nested parsing of" - "IFLA_VFINFO_LIST failed."); + "IFLA_VFINFO_LIST failed."); return; } if (nla_parse_nested(tb_vfinfo, IFLA_VF_MAX, - tb_vfinfo_list, ifla_vf_policy)) { + tb_vfinfo_list, ifla_vf_policy)) { VIR_DEBUG("nested parsing of " - "IFLA_VF_INFO failed."); + "IFLA_VF_INFO failed."); return; } } @@ -691,7 +691,7 @@ virNetDevMacVLanVPortProfileCallback(struct nlmsghdr *h= dr, continue; } if (nla_parse_nested(tb3, IFLA_PORT_MAX, tb_vf_ports, - ifla_port_policy)) { + ifla_port_policy)) { VIR_DEBUG("nested parsing on level 2" " failed."); } @@ -742,8 +742,8 @@ virNetDevMacVLanVPortProfileCallback(struct nlmsghdr *h= dr, } =20 if (tb3[IFLA_PORT_RESPONSE]) { - VIR_DEBUG("IFLA_PORT_RESPONSE =3D %d", *(uint16_t *) - RTA_DATA(tb3[IFLA_PORT_RESPONSE])); + VIR_DEBUG("IFLA_PORT_RESPONSE =3D %d", + *(uint16_t *) RTA_DATA(tb3[IFLA_PORT_RESPONSE])); } } } @@ -1106,7 +1106,7 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char= *ifname, =20 if ((virNetDevReadNetConfig(linkdev, -1, stateDir, &adminMAC, &vlan, &MAC) =3D=3D 0) && - (adminMAC || vlan || MAC)) { + (adminMAC || vlan || MAC)) { =20 ignore_value(virNetDevSetNetConfig(linkdev, -1, adminMAC, vlan, MAC, !!vlan= )); diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index a5de541..b2756f9 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -139,10 +139,10 @@ virNetDevOpenvswitchConstructVlans(virCommandPtr cmd,= virNetDevVlanPtr virtVlan) * Returns 0 in case of success or -1 in case of failure. */ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, - const virMacAddr *macaddr, - const unsigned char *vmuuid, - virNetDevVPortProfilePtr ovsport, - virNetDevVlanPtr virtVlan) + const virMacAddr *macaddr, + const unsigned char *vmuuid, + virNetDevVPortProfilePtr ovsport, + virNetDevVlanPtr virtVlan) { char macaddrstr[VIR_MAC_STRING_BUFLEN]; char ifuuidstr[VIR_UUID_STRING_BUFLEN]; @@ -182,21 +182,21 @@ int virNetDevOpenvswitchAddPort(const char *brname, c= onst char *ifname, =20 if (ovsport->profileID[0] =3D=3D '\0') { virCommandAddArgList(cmd, - "--", "set", "Interface", ifname, attachedmac_ex_i= d, - "--", "set", "Interface", ifname, ifaceid_ex_id, - "--", "set", "Interface", ifname, vmid_ex_id, - "--", "set", "Interface", ifname, - "external-ids:iface-status=3Dactive", - NULL); + "--", "set", "Interface", ifname, attachedmac= _ex_id, + "--", "set", "Interface", ifname, ifaceid_ex_= id, + "--", "set", "Interface", ifname, vmid_ex_id, + "--", "set", "Interface", ifname, + "external-ids:iface-status=3Dactive", + NULL); } else { virCommandAddArgList(cmd, - "--", "set", "Interface", ifname, attachedmac_ex_i= d, - "--", "set", "Interface", ifname, ifaceid_ex_id, - "--", "set", "Interface", ifname, vmid_ex_id, - "--", "set", "Interface", ifname, profile_ex_id, - "--", "set", "Interface", ifname, - "external-ids:iface-status=3Dactive", - NULL); + "--", "set", "Interface", ifname, attachedmac= _ex_id, + "--", "set", "Interface", ifname, ifaceid_ex_= id, + "--", "set", "Interface", ifname, vmid_ex_id, + "--", "set", "Interface", ifname, profile_ex_= id, + "--", "set", "Interface", ifname, + "external-ids:iface-status=3Dactive", + NULL); } =20 if (virCommandRun(cmd, NULL) < 0) { diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprof= ile.c index 215d649..b6cd0e6 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -813,8 +813,8 @@ virNetDevVPortProfileOpSetLink(const char *ifname, int = ifindex, =20 if (err->error) { virReportSystemError(-err->error, - _("error during virtual port configuration of ifindex %d"), - ifindex); + _("error during virtual port configuratio= n of ifindex %d"), + ifindex); goto cleanup; } break; @@ -979,9 +979,9 @@ virNetDevVPortProfileOpCommon(const char *ifname, int i= findex, /* keep trying... */ } else { virReportSystemError(EINVAL, - _("error %d during port-profile setlink on " - "interface %s (%d)"), - status, ifname, ifindex); + _("error %d during port-profile setlink o= n " + "interface %s (%d)"), + status, ifname, ifindex); rc =3D -1; break; } @@ -1347,13 +1347,13 @@ virNetDevVPortProfileDisassociate(const char *macvt= ap_ifname, =20 #else /* ! WITH_VIRTUALPORT */ int virNetDevVPortProfileAssociate(const char *macvtap_ifname ATTRIBUTE_UN= USED, - const virNetDevVPortProfile *virtPort ATTRI= BUTE_UNUSED, - const virMacAddr *macvtap_macaddr ATTRIBUTE= _UNUSED, - const char *linkdev ATTRIBUTE_UNUSED, - int vf ATTRIBUTE_UNUSED, - const unsigned char *vmuuid ATTRIBUTE_UNUSE= D, - virNetDevVPortProfileOp vmOp ATTRIBUTE_UNUS= ED, - bool setlink_only ATTRIBUTE_UNUSED) + const virNetDevVPortProfile *virtPort A= TTRIBUTE_UNUSED, + const virMacAddr *macvtap_macaddr ATTRI= BUTE_UNUSED, + const char *linkdev ATTRIBUTE_UNUSED, + int vf ATTRIBUTE_UNUSED, + const unsigned char *vmuuid ATTRIBUTE_U= NUSED, + virNetDevVPortProfileOp vmOp ATTRIBUTE_= UNUSED, + bool setlink_only ATTRIBUTE_UNUSED) { virReportSystemError(ENOSYS, "%s", _("Virtual port profile association not supported= on this platform")); diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index e473ccb..bf36899 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -543,9 +543,9 @@ virNetlinkNewLink(const char *ifname, NETLINK_MSG_PUT(nl_msg, IFLA_INFO_KIND, (strlen(type) + 1), type); =20 if ((STREQ(type, "macvtap") || STREQ(type, "macvlan")) && - extra_args && - extra_args->macvlan_mode && - *extra_args->macvlan_mode > 0) { + extra_args && + extra_args->macvlan_mode && + *extra_args->macvlan_mode > 0) { NETLINK_MSG_NEST_START(nl_msg, infodata, IFLA_INFO_DATA); NETLINK_MSG_PUT(nl_msg, IFLA_MACVLAN_MODE, sizeof(uint32_t), extra_args->macvlan_mode); @@ -871,7 +871,7 @@ virNetlinkEventCallback(int watch, virNetlinkEventServerLock(srv); =20 VIR_DEBUG("dispatching to max %d clients, called from event watch %d", - (int)srv->handlesCount, watch); + (int)srv->handlesCount, watch); =20 for (i =3D 0; i < srv->handlesCount; i++) { if (srv->handles[i].deleted !=3D VIR_NETLINK_HANDLE_VALID) @@ -1143,7 +1143,7 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallbac= k handleCB, VIR_DEBUG("Used %zu handle slots, adding at least %d more", srv->handlesAlloc, NETLINK_EVENT_ALLOC_EXTENT); if (VIR_RESIZE_N(srv->handles, srv->handlesAlloc, - srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT) < 0) + srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT) < = 0) goto error; } r =3D srv->handlesCount++; diff --git a/src/util/virobject.c b/src/util/virobject.c index a597ff4..b6ea299 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -60,7 +60,7 @@ struct _virClass { obj, obj->u.s.magic); \ } else { \ VIR_WARN("Object %p (%s) is not a %s instance", \ - anyobj, obj->klass->name, #objclass); \ + anyobj, obj->klass->name, #objclass); \ } \ } while (0) =20 diff --git a/src/util/virpci.c b/src/util/virpci.c index fb3f04f..6164d7d 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -60,13 +60,13 @@ VIR_ENUM_IMPL(virPCIStubDriver, VIR_PCI_STUB_DRIVER_LAS= T, "pciback", /* XEN */ "pci-stub", /* KVM */ "vfio-pci", /* VFIO */ -); + ); =20 VIR_ENUM_IMPL(virPCIHeader, VIR_PCI_HEADER_LAST, "endpoint", "pci-bridge", "cardbus-bridge", -); + ); =20 struct _virPCIDevice { virPCIDeviceAddress address; diff --git a/src/util/virperf.c b/src/util/virperf.c index 23f7703..fe51681 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -212,8 +212,8 @@ virPerfEventEnable(virPerfPtr perf, return 0; =20 if (event_attr->attrType =3D=3D 0 && (type =3D=3D VIR_PERF_EVENT_CMT || - type =3D=3D VIR_PERF_EVENT_MBMT || - type =3D=3D VIR_PERF_EVENT_MBML)) { + type =3D=3D VIR_PERF_EVENT_MBMT || + type =3D=3D VIR_PERF_EVENT_MBML)) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("unable to enable host cpu perf event for %s"), virPerfEventTypeToString(type)); diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 3988f55..c749e5f 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -702,7 +702,7 @@ int virProcessSetNamespaces(size_t nfdlist, =20 if (nfdlist =3D=3D 0) { virReportInvalidArg(nfdlist, "%s", - _("Expected at least one file descriptor")); + _("Expected at least one file descriptor")); return -1; } for (i =3D 0; i < nfdlist; i++) { diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 13ad741..115109c 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -117,10 +117,10 @@ virQEMUBuildCommandLineJSONIterate(const char *key, return -1; =20 return virQEMUBuildCommandLineJSONRecurse(tmpkey, value, data->buf, - data->arrayFunc, false); + data->arrayFunc, false); } else { return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, - data->arrayFunc, false); + data->arrayFunc, false); } } =20 diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 4b5442f..8635228 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -702,7 +702,7 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl, virReportError(VIR_ERR_INTERNAL_ERROR, _("level %u cache size %llu does not match " "expected size %llu"), - level, i_type->size, size); + level, i_type->size, size); goto error; } i_type->max_cache_id++; @@ -1430,9 +1430,8 @@ virResctrlAllocGetGroup(virResctrlInfoPtr resctrl, { char *schemata =3D NULL; int rv =3D virFileReadValueString(&schemata, - SYSFS_RESCTRL_PATH - "/%s/schemata", - groupname); + SYSFS_RESCTRL_PATH "/%s/schemata", + groupname); =20 *alloc =3D NULL; =20 diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index eee725d..6f7da53 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -1168,7 +1168,7 @@ virSocketAddrIsNumericLocalhost(const char *addr) switch (res.data.stor.ss_family) { case AF_INET: return memcmp(&res.data.inet4.sin_addr.s_addr, &tmp.s_addr, - sizeof(res.data.inet4.sin_addr.s_addr)) =3D=3D 0; + sizeof(res.data.inet4.sin_addr.s_addr)) =3D=3D 0; case AF_INET6: return IN6_IS_ADDR_LOOPBACK(&res.data.inet6.sin6_addr); } diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryptio= n.c index 77c46fa..80962ed 100644 --- a/src/util/virstorageencryption.c +++ b/src/util/virstorageencryption.c @@ -300,7 +300,7 @@ virStorageEncryptionParseNode(xmlNodePtr node, /* If no cipher node, then fail */ if (!encdef->encinfo.cipher_name) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("ivgen element found, but cipher is miss= ing")); + _("ivgen element found, but cipher is missi= ng")); goto cleanup; } =20 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 927223e..1dabc88 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -459,8 +459,7 @@ qcow2GetBackingStoreFormat(int *format, case QCOW2_HDR_EXTENSION_BACKING_FORMAT: if (buf[offset+len] !=3D '\0') break; - *format =3D virStorageFileFormatTypeFromString( - ((const char *)buf)+offset); + *format =3D virStorageFileFormatTypeFromString(buf+offset); if (*format <=3D VIR_STORAGE_FILE_NONE) return -1; } @@ -828,16 +827,14 @@ virStorageFileProbeFormatFromBuf(const char *path, =20 /* First check file magic */ for (i =3D 0; i < VIR_STORAGE_FILE_LAST; i++) { - if (virStorageFileMatchesMagic( - fileTypeInfo[i].magicOffset, - fileTypeInfo[i].magic, - buf, buflen)) { - if (!virStorageFileMatchesVersion( - fileTypeInfo[i].versionOffset, - fileTypeInfo[i].versionSize, - fileTypeInfo[i].versionNumbers, - fileTypeInfo[i].endian, - buf, buflen)) { + if (virStorageFileMatchesMagic(fileTypeInfo[i].magicOffset, + fileTypeInfo[i].magic, + buf, buflen)) { + if (!virStorageFileMatchesVersion(fileTypeInfo[i].versionOffse= t, + fileTypeInfo[i].versionSize, + fileTypeInfo[i].versionNumbe= rs, + fileTypeInfo[i].endian, + buf, buflen)) { possibleFormat =3D i; continue; } @@ -853,8 +850,7 @@ virStorageFileProbeFormatFromBuf(const char *path, =20 /* No magic, so check file extension */ for (i =3D 0; i < VIR_STORAGE_FILE_LAST; i++) { - if (virStorageFileMatchesExtension( - fileTypeInfo[i].extension, path)) { + if (virStorageFileMatchesExtension(fileTypeInfo[i].extension, path= )) { format =3D i; goto cleanup; } @@ -1040,8 +1036,8 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr= meta, VIR_FREE(meta->backingStoreRaw); if (fileTypeInfo[meta->format].getBackingStore !=3D NULL) { int store =3D fileTypeInfo[meta->format].getBackingStore(&meta->ba= ckingStoreRaw, - backingFormat, - buf, len); + backingForm= at, + buf, len); if (store =3D=3D BACKING_STORE_INVALID) goto done; =20 @@ -1378,12 +1374,11 @@ int virStorageFileGetLVMKey(const char *path, * 06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky */ int status; - virCommandPtr cmd =3D virCommandNewArgList( - LVS, - "--noheadings", "--unbuffered", "--nosuffix", - "--options", "uuid", path, - NULL - ); + virCommandPtr cmd =3D virCommandNewArgList(LVS, "--noheadings", + "--unbuffered", "--nosuffix", + "--options", "uuid", path, + NULL + ); int ret =3D -1; =20 *key =3D NULL; @@ -1438,13 +1433,12 @@ int virStorageFileGetSCSIKey(const char *path, char **key) { int status; - virCommandPtr cmd =3D virCommandNewArgList( - "/lib/udev/scsi_id", - "--replace-whitespace", - "--whitelisted", - "--device", path, - NULL - ); + virCommandPtr cmd =3D virCommandNewArgList("/lib/udev/scsi_id", + "--replace-whitespace", + "--whitelisted", + "--device", path, + NULL + ); int ret =3D -1; =20 *key =3D NULL; @@ -3708,9 +3702,9 @@ virStorageSourceUpdatePhysicalSize(virStorageSourcePt= r src, case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot retrieve physical for path '%s' type '%s'"= ), - NULLSTR(src->path), - virStorageTypeToString(actual_type)); + _("cannot retrieve physical for path '%s' type '%s'= "), + NULLSTR(src->path), + virStorageTypeToString(actual_type)); return -1; break; } @@ -4675,7 +4669,7 @@ virStorageFileGetUniqueIdentifier(virStorageSourcePtr= src) if (!src->drv->backend->storageFileGetUniqueIdentifier) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unique storage file identifier not implemented f= or " - "storage type %s (protocol: %s)'"), + "storage type %s (protocol: %s)'"), virStorageTypeToString(src->type), virStorageNetProtocolTypeToString(src->protocol)); return NULL; diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 5795d90..6731f74 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1603,7 +1603,7 @@ virSysinfoBaseBoardIsEqual(virSysinfoBaseBoardDefPtr = src, =20 static bool virSysinfoChassisIsEqual(virSysinfoChassisDefPtr src, - virSysinfoChassisDefPtr dst) + virSysinfoChassisDefPtr dst) { bool identical =3D false; =20 diff --git a/src/util/viruri.c b/src/util/viruri.c index b80d924..d4b793f 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -342,7 +342,7 @@ virURIFindAliasMatch(char *const*aliases, const char *a= lias, virReportError(VIR_ERR_CONF_SYNTAX, _("Malformed 'uri_aliases' config entry '%s', " "aliases may only contain 'a-Z, 0-9, _, -'"), - *aliases); + *aliases); return -1; } =20 diff --git a/src/util/virutil.c b/src/util/virutil.c index 0341c63..0a9b2c0 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -325,7 +325,7 @@ virScaleInteger(unsigned long long *value, const char *= suffix, base =3D 1000; } else { virReportError(VIR_ERR_INVALID_ARG, - _("unknown suffix '%s'"), suffix); + _("unknown suffix '%s'"), suffix); return -1; } scale =3D 1; diff --git a/src/util/virxml.c b/src/util/virxml.c index d1926f4..bc0d4f2 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1256,7 +1256,7 @@ virXMLValidatorInit(const char *schemafile) goto error; =20 if (!(validator->rngParser =3D - xmlRelaxNGNewParserCtxt(validator->schemafile))) { + xmlRelaxNGNewParserCtxt(validator->schemafile))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to create RNG parser for %s"), validator->schemafile); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:27:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537346320357110.46179009777416; Wed, 19 Sep 2018 01:38:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BE4AC059B86; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47B7C80683; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 01F69181A369; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8J8cVYm006633 for ; Wed, 19 Sep 2018 04:38:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 599901001F5E; Wed, 19 Sep 2018 08:38:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C2A81092002 for ; Wed, 19 Sep 2018 08:38:28 +0000 (UTC) Received: from m97135.mail.qiye.163.com (m97135.mail.qiye.163.com [220.181.97.135]) by mx1.redhat.com (Postfix) with ESMTP id 696BE7F3F1 for ; Wed, 19 Sep 2018 08:38:26 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp1 (Coremail) with SMTP id h+CowACH6K8AC6Jb9vM3Ag--.63S4; Wed, 19 Sep 2018 16:38:25 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 19 Sep 2018 16:38:15 +0800 Message-Id: <20180919083819.11042-3-shi_lei@massclouds.com> In-Reply-To: <20180919083819.11042-1-shi_lei@massclouds.com> References: <20180919083819.11042-1-shi_lei@massclouds.com> X-CM-TRANSID: h+CowACH6K8AC6Jb9vM3Ag--.63S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7uFWrWF1fJrWfWw15Kry7trb_yoW5JFWxpa ySyrWfuwnYgrn7XasrAa48Xr93WrWkCrZ8Wr47Xa4kJF98CF1vqrWjgF18tryj9rs7Aw40 ga9YqF47Cr1DZrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRX6p9UUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiewHGT1rpNinaBQAAsA X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) for IP:'220.181.97.135' DOMAIN:'m97135.mail.qiye.163.com' HELO:'m97135.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 220.181.97.135 m97135.mail.qiye.163.com 220.181.97.135 m97135.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] build-aux:check-spacing: Add wrapper function of CheckFunctionBody X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Sep 2018 08:38:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds CheckFunctionBody to simplifies check-spacing. Signed-off-by: Shi Lei --- build-aux/check-spacing.pl | 61 +++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index da9a58b..c5d5a69 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -23,6 +23,45 @@ use strict; use warnings; =20 +# +# 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 +# +# Check incorrect indentation and blank first line in function body. +# For efficiency, it only checks the first line of function body. +# But it's enough for most cases. +# (It could be better that we use *state* to declare @fn_linenum and +# move it into this subroutine. But *state* requires version >=3D v5.10.) +# +sub CheckFunctionBody { + my $ret =3D 0; + my ($data, $location, $fn_linenum) =3D @_; + + # Check first line of function block + if ($$fn_linenum) { + if ($$data =3D~ /^\s*$/) { + print "Blank line before content in function body:\n$$location= "; + $ret =3D 1; + } elsif ($$data !~ /^[ ]{4}\S/) { + unless ($$data =3D~ /^[ ]\w+:$/ || $$data =3D~ /^}/) { + print "Incorrect indentation in function body:\n$$location= "; + $ret =3D 1; + } + } + $$fn_linenum =3D 0; + } + + # Detect start of function block + if ($$data =3D~ /^{$/) { + $$fn_linenum =3D $.; + } + + return $ret; +} + my $ret =3D 0; my $incomment =3D 0; =20 @@ -37,6 +76,7 @@ foreach my $file (@ARGV) { =20 while (defined (my $line =3D )) { my $data =3D $line; + my $location =3D "$file:$.:\n$line"; # For temporary modifications my $tmpdata; =20 @@ -51,26 +91,7 @@ foreach my $file (@ARGV) { =20 next if $data =3D~ /^#/; =20 - # Detect start of function block - if ($data =3D~ /^{$/) { - $fn_linenum =3D $.; - } - - # Handle first line of function block - if ($fn_linenum && $fn_linenum !=3D $.) { - if ($data =3D~ /^\s*$/) { - print "Blank line before content in function body:\n"; - print "$file:$.:\n$line"; - $ret =3D 1; - } elsif ($data !~ /^[ ]{4}\S/) { - unless ($data =3D~ /^[ ]\w+:$/ || $data =3D~ /^}/) { - print "Incorrect indentation in function body:\n"; - print "$file:$.:\n$line"; - $ret =3D 1; - } - } - $fn_linenum =3D 0; - } + $ret =3D 1 if CheckFunctionBody(\$data, \$location, \$fn_linenum); =20 # Kill contents of multi-line comments # and detect end of multi-line comments --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:27:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537346320511342.46958765863803; Wed, 19 Sep 2018 01:38:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89C1A8831E; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 565C417B68; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E4BC24A464; Wed, 19 Sep 2018 08:38:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8J8cUJJ006611 for ; Wed, 19 Sep 2018 04:38:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D0F07FCB7; Wed, 19 Sep 2018 08:38:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 948117FCBD for ; Wed, 19 Sep 2018 08:38:28 +0000 (UTC) Received: from m97135.mail.qiye.163.com (m97135.mail.qiye.163.com [220.181.97.135]) by mx1.redhat.com (Postfix) with ESMTP id 8F27E3091D4E for ; Wed, 19 Sep 2018 08:38:26 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp1 (Coremail) with SMTP id h+CowACH6K8AC6Jb9vM3Ag--.63S5; Wed, 19 Sep 2018 16:38:25 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 19 Sep 2018 16:38:16 +0800 Message-Id: <20180919083819.11042-4-shi_lei@massclouds.com> In-Reply-To: <20180919083819.11042-1-shi_lei@massclouds.com> References: <20180919083819.11042-1-shi_lei@massclouds.com> X-CM-TRANSID: h+CowACH6K8AC6Jb9vM3Ag--.63S5 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTR_BMKDUUUU X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiegHGT1qrhjYcBwAAso X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) for IP:'220.181.97.135' DOMAIN:'m97135.mail.qiye.163.com' HELO:'m97135.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 220.181.97.135 m97135.mail.qiye.163.com 220.181.97.135 m97135.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] build-aux:check-spacing: Add wrapper function of KillComments X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 19 Sep 2018 08:38:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds KillComments to simplifies check-spacing. Signed-off-by: Shi Lei --- build-aux/check-spacing.pl | 56 ++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index c5d5a69..75bcfd9 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -62,8 +62,41 @@ sub CheckFunctionBody { return $ret; } =20 +# +# KillComments: +# $_[0]: $data(inout) +# $_[1]: $incomment(inout) +# +# Remove all content of comments +# (Also, the @incomment could be declared with *state* and move it in.) +# +sub KillComments { + my ($data, $incomment) =3D @_; + + # Kill contents of multi-line comments + # and detect end of multi-line comments + if ($$incomment) { + if ($$data =3D~ m,\*/,) { + $$incomment =3D 0; + $$data =3D~ s,^.*\*/,*/,; + } else { + $$data =3D ""; + } + } + + # Kill single line comments, and detect + # start of multi-line comments + if ($$data =3D~ m,/\*.*\*/,) { + $$data =3D~ s,/\*.*\*/,/* */,; + } elsif ($$data =3D~ m,/\*,) { + $$incomment =3D 1; + $$data =3D~ s,/\*.*,/*,; + } + + return; +} + my $ret =3D 0; -my $incomment =3D 0; =20 foreach my $file (@ARGV) { # Per-file variables for multiline Curly Bracket (cb_) check @@ -71,6 +104,7 @@ foreach my $file (@ARGV) { my $cb_code =3D ""; my $cb_scolon =3D 0; my $fn_linenum =3D 0; + my $incomment =3D 0; =20 open FILE, $file; =20 @@ -93,25 +127,7 @@ foreach my $file (@ARGV) { =20 $ret =3D 1 if CheckFunctionBody(\$data, \$location, \$fn_linenum); =20 - # Kill contents of multi-line comments - # and detect end of multi-line comments - if ($incomment) { - if ($data =3D~ m,\*/,) { - $incomment =3D 0; - $data =3D~ s,^.*\*/,*/,; - } else { - $data =3D ""; - } - } - - # Kill single line comments, and detect - # start of multi-line comments - if ($data =3D~ m,/\*.*\*/,) { - $data =3D~ s,/\*.*\*/,/* */,; - } elsif ($data =3D~ m,/\*,) { - $incomment =3D 1; - $data =3D~ s,/\*.*,/*,; - } + KillComments(\$data, \$incomment); =20 # We need to match things like # --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:27:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537346314649308.72353397202085; Wed, 19 Sep 2018 01:38:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D0DB8831D; Wed, 19 Sep 2018 08:38:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 254B1183A0; Wed, 19 Sep 2018 08:38:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 79AB6181A12D; Wed, 19 Sep 2018 08:38:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8J8cUtJ006628 for ; Wed, 19 Sep 2018 04:38:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id E85B280683; Wed, 19 Sep 2018 08:38:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 822A18068D for ; Wed, 19 Sep 2018 08:38:28 +0000 (UTC) Received: from m97135.mail.qiye.163.com (m97135.mail.qiye.163.com [220.181.97.135]) by mx1.redhat.com (Postfix) with ESMTP id B794430820E7 for ; Wed, 19 Sep 2018 08:38:26 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp1 (Coremail) with SMTP id h+CowACH6K8AC6Jb9vM3Ag--.63S6; Wed, 19 Sep 2018 16:38:25 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 19 Sep 2018 16:38:17 +0800 Message-Id: <20180919083819.11042-5-shi_lei@massclouds.com> In-Reply-To: <20180919083819.11042-1-shi_lei@massclouds.com> References: <20180919083819.11042-1-shi_lei@massclouds.com> X-CM-TRANSID: h+CowACH6K8AC6Jb9vM3Ag--.63S6 X-Coremail-Antispam: 1Uf129KBjvJXoW3Ww4fKr15XrW8Zr17WrW3ZFb_yoW7tF1fpa y3A34Sy390gr18G3Wjv3WDWr15WrWvqrZ0q3sxZw4kGFWDGrnrKF4UtrZayFyY9rWUAFWj qan8uF43Gw1UurDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRX6p9UUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiewHGT1rpNinaDAAAsJ X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) for IP:'220.181.97.135' DOMAIN:'m97135.mail.qiye.163.com' HELO:'m97135.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 220.181.97.135 m97135.mail.qiye.163.com 220.181.97.135 m97135.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] build-aux:check-spacing: Add wrapper function of CheckWhiteSpaces X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 19 Sep 2018 08:38:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds CheckWhiteSpaces to simplify check-spacing. Signed-off-by: Shi Lei --- build-aux/check-spacing.pl | 204 +++++++++++++++++++------------------ 1 file changed, 106 insertions(+), 98 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index 75bcfd9..cdd991b 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -96,6 +96,111 @@ sub KillComments { return; } =20 +# +# CheckWhiteSpaces: +# $_[0]: $data(in) +# $_[1]: $location(in), which format is file-path:line-num:line-code +# +# Check whitespaces according to code spec of libvirt. +# +sub CheckWhiteSpaces { + my $ret =3D 0; + my ($data, $location) =3D @_; + + # We need to match things like + # + # int foo (int bar, bool wizz); + # foo (bar, wizz); + # + # but not match things like: + # + # typedef int (*foo)(bar wizz) + # + # we can't do this (efficiently) without + # missing things like + # + # foo (*bar, wizz); + # + # We also don't want to spoil the $data so it can be used + # later on. + + # For temporary modifications + my $tmpdata =3D $$data; + while ($tmpdata =3D~ /(\w+)\s\((?!\*)/) { + my $kw =3D $1; + + # Allow space after keywords only + if ($kw =3D~ /^(?:if|for|while|switch|return)$/) { + $tmpdata =3D~ s/(?:$kw\s\()/XXX(/; + } else { + print "Whitespace after non-keyword:\n$$location"; + $ret =3D 1; + last; + } + } + + # Require whitespace immediately after keywords + if ($$data =3D~ /\b(?:if|for|while|switch|return)\(/) { + print "No whitespace after keyword:\n$$location"; + $ret =3D 1; + } + + # Forbid whitespace between )( of a function typedef + if ($$data =3D~ /\(\*\w+\)\s+\(/) { + print "Whitespace between ')' and '(':\n$$location"; + $ret =3D 1; + } + + # Forbid whitespace following ( or prior to ) + # but allow whitespace before ) on a single line + # (optionally followed by a semicolon) + if (($$data =3D~ /\s\)/ && not $$data =3D~ /^\s+\);?$/) || + $$data =3D~ /\((?!$)\s/) { + print "Whitespace after '(' or before ')':\n$$location"; + $ret =3D 1; + } + + # Forbid whitespace before ";" or ",". Things like below are allowed: + # + # 1) The expression is empty for "for" loop. E.g. + # for (i =3D 0; ; i++) + # + # 2) An empty statement. E.g. + # while (write(statuswrite, &status, 1) =3D=3D -1 && + # errno =3D=3D EINTR) + # ; + # + if ($$data =3D~ /\s[;,]/) { + unless ($$data =3D~ /\S; ; / || + $$data =3D~ /^\s+;/) { + print "Whitespace before semicolon or comma:\n$$location"; + $ret =3D 1; + } + } + + # Require EOL, macro line continuation, or whitespace after ";". + # Allow "for (;;)" as an exception. + if ($$data =3D~ /;[^ \\\n;)]/) { + print "Invalid character after semicolon:\n$$location"; + $ret =3D 1; + } + + # Require EOL, space, or enum/struct end after comma. + if ($$data =3D~ /,[^ \\\n)}]/) { + print "Invalid character after comma:\n$$location"; + $ret =3D 1; + } + + # Require spaces around assignment '=3D', compounds and '=3D=3D' + if ($$data =3D~ /[^ ]\b[!<>&|\-+*\/%\^=3D]?=3D/ || + $$data =3D~ /=3D[^=3D \\\n]/) { + print "Spacing around '=3D' or '=3D=3D':\n$$location"; + $ret =3D 1; + } + + return $ret; +} + my $ret =3D 0; =20 foreach my $file (@ARGV) { @@ -111,8 +216,6 @@ foreach my $file (@ARGV) { while (defined (my $line =3D )) { my $data =3D $line; my $location =3D "$file:$.:\n$line"; - # For temporary modifications - my $tmpdata; =20 # Kill any quoted , ; =3D or " $data =3D~ s/'[";,=3D]'/'X'/g; @@ -129,102 +232,7 @@ foreach my $file (@ARGV) { =20 KillComments(\$data, \$incomment); =20 - # We need to match things like - # - # int foo (int bar, bool wizz); - # foo (bar, wizz); - # - # but not match things like: - # - # typedef int (*foo)(bar wizz) - # - # we can't do this (efficiently) without - # missing things like - # - # foo (*bar, wizz); - # - # We also don't want to spoil the $data so it can be used - # later on. - $tmpdata =3D $data; - while ($tmpdata =3D~ /(\w+)\s\((?!\*)/) { - my $kw =3D $1; - - # Allow space after keywords only - if ($kw =3D~ /^(?:if|for|while|switch|return)$/) { - $tmpdata =3D~ s/(?:$kw\s\()/XXX(/; - } else { - print "Whitespace after non-keyword:\n"; - print "$file:$.: $line"; - $ret =3D 1; - last; - } - } - - # Require whitespace immediately after keywords - if ($data =3D~ /\b(?:if|for|while|switch|return)\(/) { - print "No whitespace after keyword:\n"; - print "$file:$.: $line"; - $ret =3D 1; - } - - # Forbid whitespace between )( of a function typedef - if ($data =3D~ /\(\*\w+\)\s+\(/) { - print "Whitespace between ')' and '(':\n"; - print "$file:$.: $line"; - $ret =3D 1; - } - - # Forbid whitespace following ( or prior to ) - # but allow whitespace before ) on a single line - # (optionally followed by a semicolon) - if (($data =3D~ /\s\)/ && not $data =3D~ /^\s+\);?$/) || - $data =3D~ /\((?!$)\s/) { - print "Whitespace after '(' or before ')':\n"; - print "$file:$.: $line"; - $ret =3D 1; - } - - # Forbid whitespace before ";" or ",". Things like below are allow= ed: - # - # 1) The expression is empty for "for" loop. E.g. - # for (i =3D 0; ; i++) - # - # 2) An empty statement. E.g. - # while (write(statuswrite, &status, 1) =3D=3D -1 && - # errno =3D=3D EINTR) - # ; - # - if ($data =3D~ /\s[;,]/) { - unless ($data =3D~ /\S; ; / || - $data =3D~ /^\s+;/) { - print "Whitespace before semicolon or comma:\n"; - print "$file:$.: $line"; - $ret =3D 1; - } - } - - # Require EOL, macro line continuation, or whitespace after ";". - # Allow "for (;;)" as an exception. - if ($data =3D~ /;[^ \\\n;)]/) { - print "Invalid character after semicolon:\n"; - print "$file:$.: $line"; - $ret =3D 1; - } - - # Require EOL, space, or enum/struct end after comma. - if ($data =3D~ /,[^ \\\n)}]/) { - print "Invalid character after comma:\n"; - print "$file:$.: $line"; - $ret =3D 1; - } - - # Require spaces around assignment '=3D', compounds and '=3D=3D' - if ($data =3D~ /[^ ]\b[!<>&|\-+*\/%\^=3D]?=3D/ || - $data =3D~ /=3D[^=3D \\\n]/) { - print "Spacing around '=3D' or '=3D=3D':\n"; - print "$file:$.: $line"; - $ret =3D 1; - } + $ret =3D 1 if CheckWhiteSpaces(\$data, \$location); =20 # One line conditional statements with one line bodies should # not use curly brackets. --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:27:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537346315157170.36413255743457; Wed, 19 Sep 2018 01:38:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA08C3001FCD; Wed, 19 Sep 2018 08:38:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7720E80683; Wed, 19 Sep 2018 08:38:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EDB6F4BB75; Wed, 19 Sep 2018 08:38:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8J8cUcX006609 for ; Wed, 19 Sep 2018 04:38:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 89C7680686; Wed, 19 Sep 2018 08:38:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 820968068B for ; Wed, 19 Sep 2018 08:38:28 +0000 (UTC) Received: from m97135.mail.qiye.163.com (m97135.mail.qiye.163.com [220.181.97.135]) by mx1.redhat.com (Postfix) with ESMTP id DB81C308402B for ; Wed, 19 Sep 2018 08:38:26 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp1 (Coremail) with SMTP id h+CowACH6K8AC6Jb9vM3Ag--.63S7; Wed, 19 Sep 2018 16:38:26 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 19 Sep 2018 16:38:18 +0800 Message-Id: <20180919083819.11042-6-shi_lei@massclouds.com> In-Reply-To: <20180919083819.11042-1-shi_lei@massclouds.com> References: <20180919083819.11042-1-shi_lei@massclouds.com> X-CM-TRANSID: h+CowACH6K8AC6Jb9vM3Ag--.63S7 X-Coremail-Antispam: 1Uf129KBjvJXoWxZrWktFWrGFy3JFW7Kw17KFg_yoW5Xr17pa yfGr4fKrZYqr13A39ay34kXrsYgrWkGF9Fq3sav3WDAayYkrn8tr4aqryFvFy7XFykZ3y2 qa9akF47GF17ZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piTKZdUUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbieQLGT1qrhQkffwAAsv X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) for IP:'220.181.97.135' DOMAIN:'m97135.mail.qiye.163.com' HELO:'m97135.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 220.181.97.135 m97135.mail.qiye.163.com 220.181.97.135 m97135.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/6] build-aux:check-spacing: Add wrapper function of CheckCurlyBrackets X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 19 Sep 2018 08:38:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds CheckCurlyBrackets to simplify check-spacing. Signed-off-by: Shi Lei --- build-aux/check-spacing.pl | 81 ++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index cdd991b..729257c 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -201,6 +201,55 @@ sub CheckWhiteSpaces { return $ret; } =20 +# +# CheckCurlyBrackets: +# $_[0]: $data(in) +# $_[1]: $file(in) +# $_[2]: $line(in) +# $_[3]: $cb_linenum(inout) +# $_[4]: $cb_code(inout) +# $_[5]: $cb_scolon(inout) +# +# Check whitespaces according to code spec of libvirt. +# +sub CheckCurlyBrackets { + my $ret =3D 0; + my ($data, $file, $line, $cb_linenum, $cb_code, $cb_scolon) =3D @_; + + # One line conditional statements with one line bodies should + # not use curly brackets. + if ($$data =3D~ /^\s*(if|while|for)\b.*\{$/) { + $$cb_linenum =3D $.; + $$cb_code =3D $$line; + $$cb_scolon =3D 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 =3D=3D $. - 1 && $$data =3D~ /^[^;]*;[^;]*$/) { + $$cb_code .=3D $$line; + $$cb_scolon =3D 1; + } + + if ($$data =3D~ /^\s*}\s*$/ && + $$cb_linenum =3D=3D $. - 2 && + $$cb_scolon) { + + print "Curly brackets around single-line body:\n"; + print "$$file:$$cb_linenum-$.:\n$$cb_code$$line"; + $ret =3D 1; + + # There _should_ be no need to reset the values; but to + # keep my inner peace... + $$cb_linenum =3D 0; + $$cb_scolon =3D 0; + $$cb_code =3D ""; + } + + return $ret; +} + my $ret =3D 0; =20 foreach my $file (@ARGV) { @@ -234,36 +283,8 @@ foreach my $file (@ARGV) { =20 $ret =3D 1 if CheckWhiteSpaces(\$data, \$location); =20 - # One line conditional statements with one line bodies should - # not use curly brackets. - if ($data =3D~ /^\s*(if|while|for)\b.*\{$/) { - $cb_linenum =3D $.; - $cb_code =3D $line; - $cb_scolon =3D 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 =3D=3D $. - 1 && $data =3D~ /^[^;]*;[^;]*$/) { - $cb_code .=3D $line; - $cb_scolon =3D 1; - } - - if ($data =3D~ /^\s*}\s*$/ && - $cb_linenum =3D=3D $. - 2 && - $cb_scolon) { - - print "Curly brackets around single-line body:\n"; - print "$file:$cb_linenum-$.:\n$cb_code$line"; - $ret =3D 1; - - # There _should_ be no need to reset the values; but to - # keep my inner peace... - $cb_linenum =3D 0; - $cb_scolon =3D 0; - $cb_code =3D ""; - } + $ret =3D 1 if CheckCurlyBrackets(\$data, \$file, \$line, + \$cb_linenum, \$cb_code, \$cb_scolo= n); } close FILE; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:27:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537346325004930.359334944305; Wed, 19 Sep 2018 01:38:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA0C0300295A; Wed, 19 Sep 2018 08:38:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 937F87E6AB; Wed, 19 Sep 2018 08:38:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 38D61181A530; Wed, 19 Sep 2018 08:38:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8J8cUP6006610 for ; Wed, 19 Sep 2018 04:38:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9E3187FCB8; Wed, 19 Sep 2018 08:38:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94E9E7FCBE for ; Wed, 19 Sep 2018 08:38:29 +0000 (UTC) Received: from m97135.mail.qiye.163.com (m97135.mail.qiye.163.com [220.181.97.135]) by mx1.redhat.com (Postfix) with ESMTP id 65750C0587DF for ; Wed, 19 Sep 2018 08:38:27 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp1 (Coremail) with SMTP id h+CowACH6K8AC6Jb9vM3Ag--.63S8; Wed, 19 Sep 2018 16:38:26 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 19 Sep 2018 16:38:19 +0800 Message-Id: <20180919083819.11042-7-shi_lei@massclouds.com> In-Reply-To: <20180919083819.11042-1-shi_lei@massclouds.com> References: <20180919083819.11042-1-shi_lei@massclouds.com> X-CM-TRANSID: h+CowACH6K8AC6Jb9vM3Ag--.63S8 X-Coremail-Antispam: 1Uf129KBjvJXoWxCF48KFykur47uFWDAry8uFg_yoWrKFWrpF 4rKws5Cr4DXr1xA34xK34UXrnxX3ykKF1UJr17Ja1kJFyUG3WqqrW2qa48ZFWUZr48A3yU Wayaqan8ur1jvrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRrwIgUUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiEQLGT1nxsGtljQAAsB X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Sep 2018 08:38:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Sep 2018 08:38:28 +0000 (UTC) for IP:'220.181.97.135' DOMAIN:'m97135.mail.qiye.163.com' HELO:'m97135.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 220.181.97.135 m97135.mail.qiye.163.com 220.181.97.135 m97135.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/6] build-aux:check-spacing: Introduce a new rule to check misaligned stuff in parenthesises X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 19 Sep 2018 08:38:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch introduces a new rule to check misaligned stuff in parenthesis: 1. For misaligned arguments of function 2. For misaligned conditions of [if|while|switch|...] There're too much misalignment, so it adds a temporary filter which permits 'src/util' now. It _should_ be removed as soon as fixing all. Signed-off-by: Shi Lei --- build-aux/check-spacing.pl | 104 ++++++++++++++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 8 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index 729257c..d36b004 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -100,6 +100,7 @@ sub KillComments { # 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 # # Check whitespaces according to code spec of libvirt. # @@ -209,6 +210,7 @@ sub CheckWhiteSpaces { # $_[3]: $cb_linenum(inout) # $_[4]: $cb_code(inout) # $_[5]: $cb_scolon(inout) +# Returns 0 in case of success or 1 on failure # # Check whitespaces according to code spec of libvirt. # @@ -250,6 +252,74 @@ sub CheckCurlyBrackets { return $ret; } =20 +# +# CheckMisalignment: +# $_[0]: $data(in) +# $_[1]: $file(in) +# $_[2]: $line(in) +# $_[3]: @paren_stack(inout), which maintains information +# of the parenthesis +# Returns 0 in case of success or 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 =3D 0; + my ($data, $file, $line, $paren_stack) =3D @_; + + # Check alignment based on @paren_stack + if (@$paren_stack) { + if ($$data =3D~ /(\S+.*$)/) { + my $pos =3D $$paren_stack[-1][0]; + my $linenum =3D $$paren_stack[-1][1]; + my $code =3D $$paren_stack[-1][2]; + if ($pos + 1 !=3D length($`)) { + my $pad =3D ""; + if ($. > $linenum + 1) { + $pad =3D " " x $pos . " ...\n"; + } + print "Misaligned line in parenthesis:\n"; + print "$$file:$linenum-$.:\n$code$pad$$line\n"; + $ret =3D 1; + } + } + } + + # Maintain @paren_stack + if ($$data =3D~ /.*[()]/) { + my $pos =3D 0; + my $temp =3D $$data; + + # Kill the content between matched parenthesis and themselves + # within the current line. + $temp =3D~ s,(\((?:[^()]++|(?R))*+\)),"X" x (length $&),ge; + + # Pop a item for the open-paren when finding close-paren + while (($pos =3D index($temp, "\)", $pos)) >=3D 0) { + if (@$paren_stack) { + pop(@$paren_stack); + $pos++; + } else { + print "Warning: found unbalanced parenthesis:\n"; + print "$$file:$.:\n$$line\n"; + $ret =3D 1; + last; + } + } + + # Push the item for open-paren on @paren_stack + # @item =3D [ position of the open-paren, linenum, code-line ] + while (($pos =3D index($temp, "\(", $pos)) >=3D 0) { + push @$paren_stack, [$pos, $., $$line]; + $pos++; + } + } + + return $ret; +} + my $ret =3D 0; =20 foreach my $file (@ARGV) { @@ -259,32 +329,50 @@ foreach my $file (@ARGV) { my $cb_scolon =3D 0; my $fn_linenum =3D 0; my $incomment =3D 0; + my @paren_stack; =20 open FILE, $file; =20 while (defined (my $line =3D )) { + my $has_define =3D 0; my $data =3D $line; my $location =3D "$file:$.:\n$line"; =20 # Kill any quoted , ; =3D or " $data =3D~ s/'[";,=3D]'/'X'/g; =20 - # Kill any quoted strings - $data =3D~ s,"(?:[^\\\"]|\\.)*","XXX",g; + # Kill any quoted strings. Replace with equal-length "XXXX..." + $data =3D~ s,"(([^\\\"]|\\.)*)","\"".'X'x(length $1)."\"",ge; + $data =3D~ s,'(([^\\\']|\\.)*)',"\'".'X'x(length $1)."\'",ge; =20 # Kill any C++ style comments $data =3D~ s,//.*$,//,; =20 - next if $data =3D~ /^#/; + $has_define =3D 1 if $data =3D~ /(?:^#\s*define\b)/; + if (not $has_define) { + # Ignore all macros except for #define + next if $data =3D~ /^#/; =20 - $ret =3D 1 if CheckFunctionBody(\$data, \$location, \$fn_linenum); + $ret =3D 1 if CheckFunctionBody(\$data, \$location, \$fn_linen= um); =20 - KillComments(\$data, \$incomment); + KillComments(\$data, \$incomment); + + $ret =3D 1 if CheckWhiteSpaces(\$data, \$location); + + $ret =3D 1 if CheckCurlyBrackets(\$data, \$file, \$line, + \$cb_linenum, \$cb_code, \$cb_s= colon); + } =20 - $ret =3D 1 if CheckWhiteSpaces(\$data, \$location); + ##################################################################= ### + # Temporary Filter for CheckMisalignment: + # Here we introduce a white-list of path, since there're + # too much misalignment. + # We _need_ fix these misalignment in batches. + # We _should_ remove it as soon as fixing all. + ##################################################################= ### + next unless $file =3D~ /^src\/util\//; =20 - $ret =3D 1 if CheckCurlyBrackets(\$data, \$file, \$line, - \$cb_linenum, \$cb_code, \$cb_scolo= n); + $ret =3D 1 if CheckMisalignment(\$data, \$file, \$line, \@paren_st= ack); } close FILE; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list