qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: "Cédric Le Goater" <clg@redhat.com>, qemu-devel@nongnu.org
Cc: Zhenzhong Duan <zhenzhong.duan@intel.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Khem Raj <raj.khem@gmail.com>
Subject: Re: [PATCH] vfio/container: Replace basename with g_path_get_basename
Date: Wed, 20 Dec 2023 14:59:24 +0100	[thread overview]
Message-ID: <26ed00e2-0f55-42fe-b601-ef4dada285ad@redhat.com> (raw)
In-Reply-To: <20231220135302.932039-1-clg@redhat.com>

Hi Cédric,

On 12/20/23 14:53, Cédric Le Goater wrote:
> 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>
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Eric
> ---
>  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;



  reply	other threads:[~2023-12-20 14:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 13:53 [PATCH] vfio/container: Replace basename with g_path_get_basename Cédric Le Goater
2023-12-20 13:59 ` Eric Auger [this message]
2023-12-20 15:09 ` Zhao Liu
2023-12-20 17:05   ` Cédric Le Goater
2023-12-20 17:01 ` Cédric Le Goater
2023-12-21  2:44 ` Duan, Zhenzhong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26ed00e2-0f55-42fe-b601-ef4dada285ad@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=clg@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=raj.khem@gmail.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).