[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/17] vfio/container: Replace basename with g_path_get_basename
|
From: |
Cédric Le Goater |
|
Subject: |
[PULL 11/17] vfio/container: Replace basename with g_path_get_basename |
|
Date: |
Mon, 8 Jan 2024 08:32:26 +0100 |
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>
---
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
688cf23bab88f85246378bc5a7da3c51ea6b79d9..8d334f52f2438d05f632502e07ffd4dc2ec76cb5
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.43.0
- [PULL 00/17] vfio queue, Cédric Le Goater, 2024/01/08
- [PULL 02/17] vfio/container: Introduce vfio_legacy_setup() for further cleanups, Cédric Le Goater, 2024/01/08
- [PULL 04/17] vfio/container: Introduce a VFIOIOMMU QOM interface, Cédric Le Goater, 2024/01/08
- [PULL 06/17] vfio/container: Intoduce a new VFIOIOMMUClass::setup handler, Cédric Le Goater, 2024/01/08
- [PULL 07/17] vfio/spapr: Introduce a sPAPR VFIOIOMMU QOM interface, Cédric Le Goater, 2024/01/08
- [PULL 03/17] vfio/container: Initialize VFIOIOMMUOps under vfio_init_container(), Cédric Le Goater, 2024/01/08
- [PULL 01/17] vfio/spapr: Extend VFIOIOMMUOps with a release handler, Cédric Le Goater, 2024/01/08
- [PULL 05/17] vfio/container: Introduce a VFIOIOMMU legacy QOM interface, Cédric Le Goater, 2024/01/08
- [PULL 08/17] vfio/iommufd: Introduce a VFIOIOMMU iommufd QOM interface, Cédric Le Goater, 2024/01/08
- [PULL 09/17] vfio/spapr: Only compile sPAPR IOMMU support when needed, Cédric Le Goater, 2024/01/08
- [PULL 11/17] vfio/container: Replace basename with g_path_get_basename,
Cédric Le Goater <=
- [PULL 10/17] vfio/iommufd: Remove CONFIG_IOMMUFD usage, Cédric Le Goater, 2024/01/08
- [PULL 12/17] hw/vfio: fix iteration over global VFIODevice list, Cédric Le Goater, 2024/01/08
- [PULL 13/17] vfio/iommufd: Remove the use of stat() to check file existence, Cédric Le Goater, 2024/01/08
- [PULL 14/17] vfio/container: Rename vfio_init_container to vfio_set_iommu, Cédric Le Goater, 2024/01/08
- [PULL 15/17] vfio/migration: Add helper function to set state or reset device, Cédric Le Goater, 2024/01/08
- [PULL 16/17] backends/iommufd: Remove check on number of backend users, Cédric Le Goater, 2024/01/08
- [PULL 17/17] backends/iommufd: Remove mutex, Cédric Le Goater, 2024/01/08
- Re: [PULL 00/17] vfio queue, Peter Maydell, 2024/01/08