forked from rpms/qemu-kvm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.1 KiB
60 lines
2.1 KiB
9 months ago
|
From 8d3857c7877da58ed0c6b62cf2714c4127350522 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <clg@redhat.com>
|
||
|
Date: Wed, 20 Dec 2023 14:53:02 +0100
|
||
|
Subject: [PATCH 059/101] vfio/container: Replace basename with
|
||
|
g_path_get_basename
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
RH-Author: Eric Auger <eric.auger@redhat.com>
|
||
|
RH-MergeRequest: 211: IOMMUFD backend backport
|
||
|
RH-Jira: RHEL-19302 RHEL-21057
|
||
|
RH-Acked-by: Cédric Le Goater <clg@redhat.com>
|
||
|
RH-Acked-by: Sebastian Ott <sebott@redhat.com>
|
||
|
RH-Commit: [58/67] 56a90f23dadc89271b1fff014fc64ade87c1a4cb (eauger1/centos-qemu-kvm)
|
||
|
|
||
|
g_path_get_basename() is a portable utility function that has the
|
||
|
advantage of not modifing the string argument. It also fixes a compile
|
||
|
breakage with the Musl C library reported in [1].
|
||
|
|
||
|
[1] https://lore.kernel.org/all/20231212010228.2701544-1-raj.khem@gmail.com/
|
||
|
|
||
|
Reported-by: Khem Raj <raj.khem@gmail.com>
|
||
|
Reviewed-by: Eric Auger <eric.auger@redhat.com>
|
||
|
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
|
||
|
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
Signed-off-by: Cédric Le Goater <clg@redhat.com>
|
||
|
(cherry picked from commit 213ae3ffda463c0503e39e0cf827511b5298c314)
|
||
|
Signed-off-by: Eric Auger <eric.auger@redhat.com>
|
||
|
---
|
||
|
hw/vfio/container.c | 5 +++--
|
||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
|
||
|
index 688cf23bab..8d334f52f2 100644
|
||
|
--- a/hw/vfio/container.c
|
||
|
+++ b/hw/vfio/container.c
|
||
|
@@ -869,7 +869,8 @@ static void vfio_put_base_device(VFIODevice *vbasedev)
|
||
|
|
||
|
static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp)
|
||
|
{
|
||
|
- char *tmp, group_path[PATH_MAX], *group_name;
|
||
|
+ char *tmp, group_path[PATH_MAX];
|
||
|
+ g_autofree char *group_name = NULL;
|
||
|
int ret, groupid;
|
||
|
ssize_t len;
|
||
|
|
||
|
@@ -885,7 +886,7 @@ static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp)
|
||
|
|
||
|
group_path[len] = 0;
|
||
|
|
||
|
- group_name = basename(group_path);
|
||
|
+ group_name = g_path_get_basename(group_path);
|
||
|
if (sscanf(group_name, "%d", &groupid) != 1) {
|
||
|
error_setg_errno(errp, errno, "failed to read %s", group_path);
|
||
|
return -errno;
|
||
|
--
|
||
|
2.39.3
|
||
|
|