Commit f0169f4d caused a build failure with CLang due to potentially
uninitialized variable

../src/qemu/qemu_migration_params.c:825:17: error: variable 'nchannels'
is used uninitialized whenever '&&' condition is false
[-Werror,-Wsometimes-uninitialized]
  825 |             if (params && virTypedParamsGetInt(params, nparams,
      |                 ^~~~~~
../src/qemu/qemu_migration_params.c:830:17: note: uninitialized use occurs here
  830 |             if (nchannels < 1) {
      |                 ^~~~~~~~~

Initialize the number of channels to 1, the default value when the
number of channels is not specified.

Fixes: f0169f4d6ce3915cf70bc3e21fa874369e22c840
Signed-off-by: Jim Fehlig <jfeh...@suse.com>
---

Is it valid to specify '--parallel' without '--parallel-channels'? If so,
should the number of channels default to 1?

 src/qemu/qemu_migration_params.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index b696b0d13e..f8b9e2bd7e 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -820,7 +820,7 @@ qemuMigrationParamsForSave(virTypedParameterPtr params,
             return NULL;
 
         if (flags & VIR_DOMAIN_SAVE_PARALLEL) {
-            int nchannels;
+            int nchannels = 1;
 
             if (params && virTypedParamsGetInt(params, nparams,
                                                
VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS,
-- 
2.43.0

Reply via email to