Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
5211c907
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5211c907
编写于
4月 20, 2016
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conf: disk: Remove custom single-use temporary variables
Use a single temporary variable instead shortening the code.
上级
ffaacefa
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
86 deletion
+51
-86
src/conf/domain_conf.c
src/conf/domain_conf.c
+51
-86
未找到文件。
src/conf/domain_conf.c
浏览文件 @
5211c907
...
@@ -6920,110 +6920,84 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
...
@@ -6920,110 +6920,84 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
xmlNodePtr cur)
xmlNodePtr cur)
{
{
char *tmp = NULL;
char *tmp = NULL;
char *cachetag = NULL;
char *error_policy = NULL;
char *rerror_policy = NULL;
char *iotag = NULL;
char *ioeventfd = NULL;
char *event_idx = NULL;
char *copy_on_read = NULL;
char *discard = NULL;
char *driverIOThread = NULL;
int ret = -1;
int ret = -1;
def->src->driverName = virXMLPropString(cur, "name");
def->src->driverName = virXMLPropString(cur, "name");
cachetag = virXMLPropString(cur, "cache");
error_policy = virXMLPropString(cur, "error_policy");
if ((tmp = virXMLPropString(cur, "cache")) &&
rerror_policy = virXMLPropString(cur, "rerror_policy");
(def->cachemode = virDomainDiskCacheTypeFromString(tmp)) < 0) {
iotag = virXMLPropString(cur, "io");
ioeventfd = virXMLPropString(cur, "ioeventfd");
event_idx = virXMLPropString(cur, "event_idx");
copy_on_read = virXMLPropString(cur, "copy_on_read");
discard = virXMLPropString(cur, "discard");
driverIOThread = virXMLPropString(cur, "iothread");
if (cachetag &&
(def->cachemode = virDomainDiskCacheTypeFromString(cachetag)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk cache mode '%s'"),
cachetag
);
_("unknown disk cache mode '%s'"),
tmp
);
goto cleanup;
goto cleanup;
}
}
VIR_FREE(tmp);
if (
error_policy
&&
if (
(tmp = virXMLPropString(cur, "error_policy"))
&&
(def->error_policy = virDomainDiskErrorPolicyTypeFromString(
error_policy
)) <= 0) {
(def->error_policy = virDomainDiskErrorPolicyTypeFromString(
tmp
)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk error policy '%s'"),
error_policy
);
_("unknown disk error policy '%s'"),
tmp
);
goto cleanup;
goto cleanup;
}
}
VIR_FREE(tmp);
if (rerror_policy &&
if ((tmp = virXMLPropString(cur, "rerror_policy")) &&
(((def->rerror_policy
(((def->rerror_policy = virDomainDiskErrorPolicyTypeFromString(tmp)) <= 0) ||
= virDomainDiskErrorPolicyTypeFromString(rerror_policy)) <= 0) ||
(def->rerror_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE))) {
(def->rerror_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk read error policy '%s'"),
_("unknown disk read error policy '%s'"), tmp);
rerror_policy);
goto cleanup;
goto cleanup;
}
}
VIR_FREE(tmp);
if (iotag) {
if ((tmp = virXMLPropString(cur, "io")) &&
if ((def->iomode = virDomainDiskIoTypeFromString(iotag)) <= 0) {
(def->iomode = virDomainDiskIoTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk io mode '%s'"), iotag);
_("unknown disk io mode '%s'"), tmp);
goto cleanup;
goto cleanup;
}
}
}
VIR_FREE(tmp);
if (ioeventfd) {
if ((tmp = virXMLPropString(cur, "ioeventfd")) &&
int val;
(def->ioeventfd = virTristateSwitchTypeFromString(tmp)) <= 0) {
if ((val = virTristateSwitchTypeFromString(ioeventfd)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk ioeventfd mode '%s'"), tmp);
_("unknown disk ioeventfd mode '%s'"),
goto cleanup;
ioeventfd);
goto cleanup;
}
def->ioeventfd = val;
}
}
VIR_FREE(tmp);
if (event_idx) {
if ((tmp = virXMLPropString(cur, "event_idx")) &&
int idx;
(def->event_idx = virTristateSwitchTypeFromString(tmp)) <= 0) {
if ((idx = virTristateSwitchTypeFromString(event_idx)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk event_idx mode '%s'"), tmp);
_("unknown disk event_idx mode '%s'"),
goto cleanup;
event_idx);
goto cleanup;
}
def->event_idx = idx;
}
}
VIR_FREE(tmp);
if (copy_on_read) {
if ((tmp = virXMLPropString(cur, "copy_on_read")) &&
int cor;
(def->copy_on_read = virTristateSwitchTypeFromString(tmp)) <= 0) {
if ((cor = virTristateSwitchTypeFromString(copy_on_read)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk copy_on_read mode '%s'"), tmp);
_("unknown disk copy_on_read mode '%s'"),
goto cleanup;
copy_on_read);
goto cleanup;
}
def->copy_on_read = cor;
}
}
VIR_FREE(tmp);
if (discard) {
if ((tmp = virXMLPropString(cur, "discard")) &&
if ((def->discard = virDomainDiskDiscardTypeFromString(discard)) <= 0) {
(def->discard = virDomainDiskDiscardTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk discard mode '%s'"), discard);
_("unknown disk discard mode '%s'"), tmp);
goto cleanup;
goto cleanup;
}
}
}
VIR_FREE(tmp);
if (driverIOThread) {
if ((tmp = virXMLPropString(cur, "iothread")) &&
if (virStrToLong_uip(driverIOThread, NULL, 10, &def->iothread) < 0 ||
(virStrToLong_uip(tmp, NULL, 10, &def->iothread) < 0 ||
def->iothread == 0) {
def->iothread == 0)) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_XML_ERROR,
_("Invalid iothread attribute in disk driver "
_("Invalid iothread attribute in disk driver element: %s"),
"element: %s"), driverIOThread);
tmp);
goto cleanup;
goto cleanup;
}
}
}
VIR_FREE(tmp);
if ((tmp = virXMLPropString(cur, "type"))) {
if ((tmp = virXMLPropString(cur, "type"))) {
if (STREQ(tmp, "aio")) {
if (STREQ(tmp, "aio")) {
...
@@ -7044,15 +7018,6 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
...
@@ -7044,15 +7018,6 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
cleanup:
cleanup:
VIR_FREE(tmp);
VIR_FREE(tmp);
VIR_FREE(cachetag);
VIR_FREE(error_policy);
VIR_FREE(rerror_policy);
VIR_FREE(iotag);
VIR_FREE(ioeventfd);
VIR_FREE(event_idx);
VIR_FREE(copy_on_read);
VIR_FREE(discard);
VIR_FREE(driverIOThread);
return ret;
return ret;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录