提交 92427948 编写于 作者: P Peter Krempa

maint: Prohibit "devname" by a syntax check rules

and tweak the code to avoid using it.
上级 72945c06
......@@ -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/.*)$$
......@@ -5601,7 +5601,7 @@ typedef enum {
} virDomainConsoleFlags;
int virDomainOpenConsole(virDomainPtr dom,
const char *devname,
const char *dev_name,
virStreamPtr st,
unsigned int flags);
......
......@@ -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, "<vlan tag='%s'", def->data.vlan.tag);
if (def->data.vlan.devname != NULL) {
if (def->data.vlan.dev_name != NULL) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
virBufferAsprintf(buf, "<interface name='%s'/>\n",
def->data.vlan.devname);
def->data.vlan.dev_name);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</vlan>\n");
} else {
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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,
......
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册