From 92427948b32088cfc7e156a4e7cab87258e207a6 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 1 Oct 2014 16:07:46 +0200 Subject: [PATCH] maint: Prohibit "devname" by a syntax check rules and tweak the code to avoid using it. --- cfg.mk | 10 ++++++++++ include/libvirt/libvirt.h.in | 2 +- src/conf/interface_conf.c | 10 +++++----- src/conf/interface_conf.h | 2 +- src/interface/interface_backend_udev.c | 2 +- src/qemu/qemu_monitor.c | 4 ++-- src/qemu/qemu_monitor.h | 6 +++--- src/util/virfile.c | 6 +++--- tools/virsh-domain.c | 4 ++-- tools/virt-host-validate-common.h | 2 +- 10 files changed, 29 insertions(+), 19 deletions(-) diff --git a/cfg.mk b/cfg.mk index ed7123b4df..352e6194c7 100644 --- a/cfg.mk +++ b/cfg.mk @@ -962,6 +962,13 @@ sc_prohibit_paren_brace: halt='Put space between closing parenthesis and opening brace' \ $(_sc_search_regexp) +# FreeBSD exports the "devname" symbol which produces a warning. +sc_prohibit_devname: + @prohibit='\bdevname\b' \ + exclude='sc_prohibit_devname' \ + halt='avoid using 'devname' as FreeBSD exports the symbol' \ + $(_sc_search_regexp) + # We don't use this feature of maint.mk. prev_version_file = /dev/null @@ -1146,3 +1153,6 @@ exclude_file_name_regexp--sc_prohibit_empty_first_line = \ exclude_file_name_regexp--sc_prohibit_useless_translation = \ ^tests/virpolkittest.c + +exclude_file_name_regexp--sc_prohibit_devname = \ + ^(tools/virsh.pod|cfg.mk|docs/.*)$$ diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 5217ab39ba..c9018c0360 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -5601,7 +5601,7 @@ typedef enum { } virDomainConsoleFlags; int virDomainOpenConsole(virDomainPtr dom, - const char *devname, + const char *dev_name, virStreamPtr st, unsigned int flags); diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index effe5adb29..10c7c099c0 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -101,7 +101,7 @@ void virInterfaceDefFree(virInterfaceDefPtr def) break; case VIR_INTERFACE_TYPE_VLAN: VIR_FREE(def->data.vlan.tag); - VIR_FREE(def->data.vlan.devname); + VIR_FREE(def->data.vlan.dev_name); break; } @@ -671,9 +671,9 @@ virInterfaceDefParseVlan(virInterfaceDefPtr def, return -1; } - def->data.vlan.devname = + def->data.vlan.dev_name = virXPathString("string(./interface/@name)", ctxt); - if (def->data.vlan.devname == NULL) { + if (def->data.vlan.dev_name == NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("vlan interface misses name attribute")); return -1; @@ -955,11 +955,11 @@ virInterfaceVlanDefFormat(virBufferPtr buf, const virInterfaceDef *def) } virBufferAsprintf(buf, "data.vlan.tag); - if (def->data.vlan.devname != NULL) { + if (def->data.vlan.dev_name != NULL) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "\n", - def->data.vlan.devname); + def->data.vlan.dev_name); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } else { diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h index 94c18ef022..ac212fb530 100644 --- a/src/conf/interface_conf.h +++ b/src/conf/interface_conf.h @@ -116,7 +116,7 @@ typedef struct _virInterfaceVlanDef virInterfaceVlanDef; typedef virInterfaceVlanDef *virInterfaceVlanDefPtr; struct _virInterfaceVlanDef { char *tag; /* TAG for vlan */ - char *devname; /* device name for vlan */ + char *dev_name; /* device name for vlan */ }; typedef struct _virInterfaceIpDef virInterfaceIpDef; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c index ecb1b2a35f..1dbbfe7c77 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1015,7 +1015,7 @@ udevGetIfaceDefVlan(struct udev *udev ATTRIBUTE_UNUSED, if (VIR_STRNDUP(ifacedef->data.vlan.tag, vid_pos, vid_len) < 0) goto cleanup; - if (VIR_STRNDUP(ifacedef->data.vlan.devname, dev_pos, dev_len) < 0) { + if (VIR_STRNDUP(ifacedef->data.vlan.dev_name, dev_pos, dev_len) < 0) { VIR_FREE(ifacedef->data.vlan.tag); goto cleanup; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c9929c3107..00c62f71b8 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1821,7 +1821,7 @@ int qemuMonitorGetBlockExtent(qemuMonitorPtr mon, unsigned long long *extent) { int ret; - VIR_DEBUG("mon=%p, dev_name=%p", mon, dev_name); + VIR_DEBUG("mon=%p, dev_name=%s", mon, dev_name); if (mon->json) ret = qemuMonitorJSONGetBlockExtent(mon, dev_name, extent); @@ -1836,7 +1836,7 @@ int qemuMonitorBlockResize(qemuMonitorPtr mon, unsigned long long size) { int ret; - VIR_DEBUG("mon=%p, devname=%p size=%llu", mon, device, size); + VIR_DEBUG("mon=%p, device=%s size=%llu", mon, device, size); if (mon->json) ret = qemuMonitorJSONBlockResize(mon, device, size); diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f0c0b0af85..63e14ccb1c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -333,7 +333,7 @@ int qemuMonitorBlockIOStatusToError(const char *status); virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon); struct qemuDomainDiskInfo * qemuMonitorBlockInfoLookup(virHashTablePtr blockInfo, - const char *devname); + const char *dev_name); int qemuMonitorGetBlockStatsInfo(qemuMonitorPtr mon, const char *dev_name, @@ -378,7 +378,7 @@ int qemuMonitorGetBlockExtent(qemuMonitorPtr mon, const char *dev_name, unsigned long long *extent); int qemuMonitorBlockResize(qemuMonitorPtr mon, - const char *devname, + const char *dev_name, unsigned long long size); int qemuMonitorSetVNCPassword(qemuMonitorPtr mon, const char *password); @@ -395,7 +395,7 @@ int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, bool online); /* XXX should we pass the virDomainDiskDefPtr instead - * and hide devname details inside monitor. Reconsider + * and hide dev_name details inside monitor. Reconsider * this when doing the QMP implementation */ int qemuMonitorEjectMedia(qemuMonitorPtr mon, diff --git a/src/util/virfile.c b/src/util/virfile.c index b3b8be2bf8..c379df569c 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -745,13 +745,13 @@ int virFileLoopDeviceAssociate(const char *file, static int -virFileNBDDeviceIsBusy(const char *devname) +virFileNBDDeviceIsBusy(const char *dev_name) { char *path; int ret = -1; if (virAsprintf(&path, SYSFS_BLOCK_DIR "/%s/pid", - devname) < 0) + dev_name) < 0) return -1; if (!virFileExists(path)) { @@ -760,7 +760,7 @@ virFileNBDDeviceIsBusy(const char *devname) else virReportSystemError(errno, _("Cannot check NBD device %s pid"), - devname); + dev_name); goto cleanup; } ret = 1; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index ce5940623d..12550ff5ed 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2570,7 +2570,7 @@ static const vshCmdOptDef opts_console[] = { .flags = VSH_OFLAG_REQ, .help = N_("domain name, id or uuid") }, - {.name = "devname", + {.name = "devname", /* sc_prohibit_devname */ .type = VSH_OT_STRING, .help = N_("character device name") }, @@ -2632,7 +2632,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshCommandOptStringReq(ctl, cmd, "devname", &name) < 0) + if (vshCommandOptStringReq(ctl, cmd, "devname", &name) < 0) /* sc_prohibit_devname */ goto cleanup; if (force) diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-common.h index a29f86c53c..25644dca8f 100644 --- a/tools/virt-host-validate-common.h +++ b/tools/virt-host-validate-common.h @@ -43,7 +43,7 @@ extern void virHostMsgFail(virHostValidateLevel level, const char *hint); extern int virHostValidateDevice(const char *hvname, - const char *devname, + const char *dev_name, virHostValidateLevel level, const char *hint); -- GitLab