computing-offload/generic_vdpa/qemu/target-ppc-use-g_autofree-in-kvmppc_read_int_cpu_dt.patch
jiangdongxu 79c4324644 add generic_vdpa basecode
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
2024-09-19 17:19:46 +08:00

44 lines
1.3 KiB
Diff

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