[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.1 14/38] vfio/container: Replace basename with g_path_get_ba
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.1 14/38] vfio/container: Replace basename with g_path_get_basename |
Date: |
Thu, 18 Jan 2024 10:52:41 +0300 |
From: Cédric Le Goater <clg@redhat.com>
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: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index 242010036a..adc3005beb 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -848,7 +848,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;
@@ -864,7 +865,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.2
- [Stable-8.2.1 04/38] target/riscv/kvm: do not use non-portable strerrorname_np(), (continued)
- [Stable-8.2.1 04/38] target/riscv/kvm: do not use non-portable strerrorname_np(), Michael Tokarev, 2024/01/18
- [Stable-8.2.1 05/38] include/ui/rect.h: fix qemu_rect_init() mis-assignment, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 06/38] configure: use a native non-cross compiler for linux-user, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 07/38] target/i386: the sgx_epc_get_section stub is reachable, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 08/38] hw/net/can/sja1000: fix bug for single acceptance filter and standard frame, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 09/38] target/riscv: Fix mcycle/minstret increment behavior, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 10/38] chardev/char.c: fix "abstract device type" error message, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 11/38] audio/audio.c: remove trailing newline in error_setg, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 12/38] hw/net: cadence_gem: Fix MDIO_OP_xxx values, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 13/38] edu: fix DMA range upper bound check, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 14/38] vfio/container: Replace basename with g_path_get_basename,
Michael Tokarev <=
- [Stable-8.2.1 15/38] hw/vfio: fix iteration over global VFIODevice list, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 16/38] hw/intc/arm_gicv3_cpuif: handle LPIs in in the list registers, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 17/38] tcg/ppc: Use new registers for LQ destination, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 18/38] util: fix build with musl libc on ppc64le, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 19/38] tests/acpi: allow tests/data/acpi/virt/SSDT.memhp changes, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 20/38] edk2: update to git snapshot, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 21/38] edk2: update build config, set PcdUninstallMemAttrProtocol = TRUE., Michael Tokarev, 2024/01/18
- [Stable-8.2.1 22/38] edk2: update binaries to git snapshot, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 23/38] tests/acpi: update expected data files, Michael Tokarev, 2024/01/18
- [Stable-8.2.1 24/38] tests/acpi: disallow tests/data/acpi/virt/SSDT.memhp changes, Michael Tokarev, 2024/01/18