[PATCH 0/2] hw/s390x/ccw: Cleanup basename() and dirname()

Zhao Liu posted 2 patches 11 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231221171921.57784-1-zhao1.liu@linux.intel.com
Maintainers: Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>
hw/s390x/s390-ccw.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
[PATCH 0/2] hw/s390x/ccw: Cleanup basename() and dirname()
Posted by Zhao Liu 11 months, 1 week ago
From: Zhao Liu <zhao1.liu@intel.com>

As commit 3e015d815b3f ("use g_path_get_basename instead of basename")
said, g_path_get_basename() and g_path_get_dirname() should be preferred
over basename() and dirname(), since g_path_get_basename() and
g_path_get_dirname() are portable utility functions that have the
advantage of not modifing the string argument.

But commit 3e015d815b3f missed a use of dirname() and basename() in
hw/s390x/ccw.

And basename() (in vfio/container) caused compile breakage with the Musl
C library [1].

To avoid similar breakage and improve portability, replace basename()
and dirname() with g_path_get_basename() and g_path_get_dirname().

[1]: https://lore.kernel.org/all/20231212010228.2701544-1-raj.khem@gmail.com/

---
Zhao Liu (2):
  hw/s390x/ccw: Replace basename() with g_path_get_basename()
  hw/s390x/ccw: Replace dirname() with g_path_get_dirname()

 hw/s390x/s390-ccw.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

-- 
2.34.1
Re: [PATCH 0/2] hw/s390x/ccw: Cleanup basename() and dirname()
Posted by Eric Farman 11 months, 1 week ago
On Fri, 2023-12-22 at 01:19 +0800, Zhao Liu wrote:
> From: Zhao Liu <zhao1.liu@intel.com>
> 
> As commit 3e015d815b3f ("use g_path_get_basename instead of
> basename")
> said, g_path_get_basename() and g_path_get_dirname() should be
> preferred
> over basename() and dirname(), since g_path_get_basename() and
> g_path_get_dirname() are portable utility functions that have the
> advantage of not modifing the string argument.
> 
> But commit 3e015d815b3f missed a use of dirname() and basename() in
> hw/s390x/ccw.
> 
> And basename() (in vfio/container) caused compile breakage with the
> Musl
> C library [1].
> 
> To avoid similar breakage and improve portability, replace basename()
> and dirname() with g_path_get_basename() and g_path_get_dirname().
> 
> [1]:
> https://lore.kernel.org/all/20231212010228.2701544-1-raj.khem@gmail.com/
> 
> ---
> Zhao Liu (2):
>   hw/s390x/ccw: Replace basename() with g_path_get_basename()
>   hw/s390x/ccw: Replace dirname() with g_path_get_dirname()
> 
>  hw/s390x/s390-ccw.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Farman <farman@linux.ibm.com>
Re: [PATCH 0/2] hw/s390x/ccw: Cleanup basename() and dirname()
Posted by Zhao Liu 11 months, 1 week ago
On Thu, Dec 21, 2023 at 04:29:31PM -0500, Eric Farman wrote:
> Date: Thu, 21 Dec 2023 16:29:31 -0500
> From: Eric Farman <farman@linux.ibm.com>
> Subject: Re: [PATCH 0/2] hw/s390x/ccw: Cleanup basename() and dirname()
> 
> On Fri, 2023-12-22 at 01:19 +0800, Zhao Liu wrote:
> > From: Zhao Liu <zhao1.liu@intel.com>
> > 
> > As commit 3e015d815b3f ("use g_path_get_basename instead of
> > basename")
> > said, g_path_get_basename() and g_path_get_dirname() should be
> > preferred
> > over basename() and dirname(), since g_path_get_basename() and
> > g_path_get_dirname() are portable utility functions that have the
> > advantage of not modifing the string argument.
> > 
> > But commit 3e015d815b3f missed a use of dirname() and basename() in
> > hw/s390x/ccw.
> > 
> > And basename() (in vfio/container) caused compile breakage with the
> > Musl
> > C library [1].
> > 
> > To avoid similar breakage and improve portability, replace basename()
> > and dirname() with g_path_get_basename() and g_path_get_dirname().
> > 
> > [1]:
> > https://lore.kernel.org/all/20231212010228.2701544-1-raj.khem@gmail.com/
> > 
> > ---
> > Zhao Liu (2):
> >   hw/s390x/ccw: Replace basename() with g_path_get_basename()
> >   hw/s390x/ccw: Replace dirname() with g_path_get_dirname()
> > 
> >  hw/s390x/s390-ccw.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> 
> Reviewed-by: Eric Farman <farman@linux.ibm.com>

Thanks Eric!

-Zhao