1 Star 0 Fork 120

Chenxi Mao/qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
target-ppc-use-g_autofree-in-kvmppc_read_int_cpu_dt.patch 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
yezengruan 提交于 2022-08-11 19:08 . Qemu update to version 6.2.0-45
From 02a15861235d29dcf89b61bf88fed2ec4ccee9dc Mon Sep 17 00:00:00 2001
From: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
Date: Thu, 4 Aug 2022 16:41:35 +0800
Subject: [PATCH 7/9] target/ppc: use g_autofree in kvmppc_read_int_cpu_dt()
This spares us a g_free() call. Let's also not use 'val' and return the
value of kvmppc_read_int_dt() directly.
Signed-off-by: jianchunfu <jianchunfu_yewu@cmss.chinamobile.com>
---
target/ppc/kvm.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index d64d7c5b4a..1a6c6b6fa0 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -1931,8 +1931,8 @@ static uint64_t kvmppc_read_int_dt(const char *filename, Error **errp)
*/
static uint64_t kvmppc_read_int_cpu_dt(const char *propname, Error **errp)
{
- char buf[PATH_MAX], *tmp;
- uint64_t val;
+ g_autofree char *tmp = NULL;
+ char buf[PATH_MAX];
if (kvmppc_find_cpu_dt(buf, sizeof(buf))) {
error_setg(errp, "Failed to read CPU property %s", propname);
@@ -1940,10 +1940,8 @@ static uint64_t kvmppc_read_int_cpu_dt(const char *propname, Error **errp)
}
tmp = g_strdup_printf("%s/%s", buf, propname);
- val = kvmppc_read_int_dt(tmp, errp);
- g_free(tmp);
- return val;
+ return kvmppc_read_int_dt(tmp, errp);
}
uint64_t kvmppc_get_clockfreq(void)
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chenxi-mao/qemu.git
git@gitee.com:chenxi-mao/qemu.git
chenxi-mao
qemu
qemu
master

搜索帮助