[PATCH] meson: Provide default values for nonexistent xenlight pkgconfig vars

Michal Privoznik posted 1 patch 1 year, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/f408fb4007bb5289425c7e017c291edfbd3e6e1a.1670846128.git.mprivozn@redhat.com
meson.build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] meson: Provide default values for nonexistent xenlight pkgconfig vars
Posted by Michal Privoznik 1 year, 4 months ago
It may happen that xenlight pkgconfig file does not contain
'xenfirmwaredir' and/or 'libexec_bin' variables, which is okay
and we have code that deals with this situation. But that code is
executed when the queried value is an empty string. This may not
always be the case and we should specifically set 'default_value'
so that the empty string is returned if pkgconfig variable
doesn't exist.

Fixes: 968479adcfa5c49b29b7b6680dcaffde1408f044
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 meson.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index f9834a36c2..3d870d77db 100644
--- a/meson.build
+++ b/meson.build
@@ -1478,8 +1478,8 @@ if not get_option('driver_libxl').disabled() and conf.has('WITH_LIBVIRTD')
   libxl_dep = dependency('xenlight', version: '>=' + libxl_version, required: get_option('driver_libxl'))
 
   if libxl_dep.found()
-    libxl_firmware_dir = libxl_dep.get_variable(pkgconfig : 'xenfirmwaredir')
-    libxl_execbin = libxl_dep.get_variable(pkgconfig : 'libexec_bin')
+    libxl_firmware_dir = libxl_dep.get_variable(pkgconfig : 'xenfirmwaredir', default_value: '')
+    libxl_execbin = libxl_dep.get_variable(pkgconfig : 'libexec_bin', default_value: '')
     if libxl_firmware_dir != ''
       conf.set_quoted('LIBXL_FIRMWARE_DIR', libxl_firmware_dir)
     endif
-- 
2.37.4
Re: [PATCH] meson: Provide default values for nonexistent xenlight pkgconfig vars
Posted by Martin Kletzander 1 year, 4 months ago
On Mon, Dec 12, 2022 at 12:55:28PM +0100, Michal Privoznik wrote:
>It may happen that xenlight pkgconfig file does not contain
>'xenfirmwaredir' and/or 'libexec_bin' variables, which is okay
>and we have code that deals with this situation. But that code is
>executed when the queried value is an empty string. This may not
>always be the case and we should specifically set 'default_value'
>so that the empty string is returned if pkgconfig variable
>doesn't exist.
>
>Fixes: 968479adcfa5c49b29b7b6680dcaffde1408f044
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

>---
> meson.build | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/meson.build b/meson.build
>index f9834a36c2..3d870d77db 100644
>--- a/meson.build
>+++ b/meson.build
>@@ -1478,8 +1478,8 @@ if not get_option('driver_libxl').disabled() and conf.has('WITH_LIBVIRTD')
>   libxl_dep = dependency('xenlight', version: '>=' + libxl_version, required: get_option('driver_libxl'))
>
>   if libxl_dep.found()
>-    libxl_firmware_dir = libxl_dep.get_variable(pkgconfig : 'xenfirmwaredir')
>-    libxl_execbin = libxl_dep.get_variable(pkgconfig : 'libexec_bin')
>+    libxl_firmware_dir = libxl_dep.get_variable(pkgconfig : 'xenfirmwaredir', default_value: '')
>+    libxl_execbin = libxl_dep.get_variable(pkgconfig : 'libexec_bin', default_value: '')
>     if libxl_firmware_dir != ''
>       conf.set_quoted('LIBXL_FIRMWARE_DIR', libxl_firmware_dir)
>     endif
>-- 
>2.37.4
>