Re: [PATCH 1/4] lib: Replace virBuildPath() with g_build_filename()

2023-10-16 Thread Peter Krempa
On Mon, Oct 16, 2023 at 10:07:48 +0200, Michal Privoznik wrote:
> Our virBuildPath() constructs a path from given arguments.
> Exactly like g_build_filename(), except the latter is more
> generic as it uses backslashes on Windows. Therefore, replace the
> former with the latter.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  docs/kbase/internals/command.rst | 2 +-
>  src/util/virfcp.c| 2 +-
>  src/util/virhook.c   | 4 ++--
>  src/util/virpci.c| 4 ++--
>  4 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/docs/kbase/internals/command.rst 
> b/docs/kbase/internals/command.rst
> index 738fb5930a..d958c9d16a 100644
> --- a/docs/kbase/internals/command.rst
> +++ b/docs/kbase/internals/command.rst
> @@ -444,7 +444,7 @@ src/util/hooks.c
>   g_autofree char *path = NULL;
>   g_autoptr(virCommand) cmd = NULL;
>  
> - virBuildPath(, LIBVIRT_HOOK_DIR, drvstr);
> + path = g_build_filename(LIBVIRT_HOOK_DIR, drvstr);

It's docs, but it's missing the NULL sentinel.

Reviewed-by: Peter Krempa 



[PATCH 1/4] lib: Replace virBuildPath() with g_build_filename()

2023-10-16 Thread Michal Privoznik
Our virBuildPath() constructs a path from given arguments.
Exactly like g_build_filename(), except the latter is more
generic as it uses backslashes on Windows. Therefore, replace the
former with the latter.

Signed-off-by: Michal Privoznik 
---
 docs/kbase/internals/command.rst | 2 +-
 src/util/virfcp.c| 2 +-
 src/util/virhook.c   | 4 ++--
 src/util/virpci.c| 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/docs/kbase/internals/command.rst b/docs/kbase/internals/command.rst
index 738fb5930a..d958c9d16a 100644
--- a/docs/kbase/internals/command.rst
+++ b/docs/kbase/internals/command.rst
@@ -444,7 +444,7 @@ src/util/hooks.c
  g_autofree char *path = NULL;
  g_autoptr(virCommand) cmd = NULL;
 
- virBuildPath(, LIBVIRT_HOOK_DIR, drvstr);
+ path = g_build_filename(LIBVIRT_HOOK_DIR, drvstr);
 
  cmd = virCommandNew(path);
 
diff --git a/src/util/virfcp.c b/src/util/virfcp.c
index bb62fa9025..052a6c99e1 100644
--- a/src/util/virfcp.c
+++ b/src/util/virfcp.c
@@ -38,7 +38,7 @@ virFCIsCapableRport(const char *rport)
 {
 g_autofree char *path = NULL;
 
-virBuildPath(, SYSFS_FC_RPORT_PATH, rport);
+path = g_build_filename(SYSFS_FC_RPORT_PATH, rport, NULL);
 
 return virFileExists(path);
 }
diff --git a/src/util/virhook.c b/src/util/virhook.c
index 50e178723f..d012bb1825 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -153,7 +153,7 @@ virHookCheck(int no, const char *driver)
 return -1;
 }
 
-virBuildPath(, LIBVIRT_HOOK_DIR, driver);
+path = g_build_filename(LIBVIRT_HOOK_DIR, driver, NULL);
 
 if (!virFileExists(path)) {
 VIR_DEBUG("No hook script %s", path);
@@ -398,7 +398,7 @@ virHookCall(int driver,
 if (extra == NULL)
 extra = "-";
 
-virBuildPath(, LIBVIRT_HOOK_DIR, drvstr);
+path = g_build_filename(LIBVIRT_HOOK_DIR, drvstr, NULL);
 
 script_ret = 1;
 
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 08b82708b1..baacde4c14 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2396,7 +2396,7 @@ virPCIGetPhysicalFunction(const char *vf_sysfs_path,
 
 *pf = NULL;
 
-virBuildPath(_link, vf_sysfs_path, "physfn");
+device_link = g_build_filename(vf_sysfs_path, "physfn", NULL);
 
 if ((*pf = virPCIGetDeviceAddressFromSysfsLink(device_link))) {
 VIR_DEBUG("PF for VF device '%s': " VIR_PCI_DEVICE_ADDRESS_FMT,
@@ -2580,7 +2580,7 @@ virPCIGetNetName(const char *device_link_sysfs_path,
 return -1;
 }
 
-virBuildPath(_sysfs_net_path, device_link_sysfs_path, "net");
+pcidev_sysfs_net_path = g_build_filename(device_link_sysfs_path, "net", 
NULL);
 
 if (virDirOpenQuiet(, pcidev_sysfs_net_path) < 0) {
 /* this *isn't* an error - caller needs to check for netname == NULL */
-- 
2.41.0