diff options
| author | Cédric Le Goater <clg@redhat.com> | 2023-12-20 14:53:02 +0100 |
|---|---|---|
| committer | Cédric Le Goater <clg@redhat.com> | 2024-01-05 21:25:20 +0100 |
| commit | 213ae3ffda463c0503e39e0cf827511b5298c314 (patch) | |
| tree | 11497c64b71db5adae1b093ff77cfa0a7c8957d7 /hw/vfio/container.c | |
| parent | c1139fa4feba8c320e4bd0a4e34af55caa5ffbb9 (diff) | |
| download | focaccia-qemu-213ae3ffda463c0503e39e0cf827511b5298c314.tar.gz focaccia-qemu-213ae3ffda463c0503e39e0cf827511b5298c314.zip | |
vfio/container: Replace basename with g_path_get_basename
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>
Diffstat (limited to 'hw/vfio/container.c')
| -rw-r--r-- | hw/vfio/container.c | 5 |
1 files 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; |