diff mbox series

migration: fix -Werror=maybe-uninitialized

Message ID 20250114104811.2612846-1-marcandre.lureau@redhat.com (mailing list archive)
State New
Headers show
Series migration: fix -Werror=maybe-uninitialized | expand

Commit Message

Marc-André Lureau Jan. 14, 2025, 10:48 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

../migration/savevm.c: In function ‘qemu_savevm_state_complete_precopy_non_iterable’:
../migration/savevm.c:1560:20: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized]
 1560 |             return ret;
      |                    ^~~

Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 migration/savevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Fabiano Rosas Jan. 14, 2025, 2:41 p.m. UTC | #1
marcandre.lureau@redhat.com writes:

> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> ../migration/savevm.c: In function ‘qemu_savevm_state_complete_precopy_non_iterable’:
> ../migration/savevm.c:1560:20: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized]
>  1560 |             return ret;
>       |                    ^~~

Weird that this didn't show up anywhere.

>
> Cc: Peter Xu <peterx@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Fabiano Rosas <farosas@suse.de>

> ---
>  migration/savevm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index c929da1ca5..6e56d4cf1d 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1557,7 +1557,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
>              migrate_set_error(ms, local_err);
>              error_report_err(local_err);
>              qemu_file_set_error(f, -EFAULT);
> -            return ret;
> +            return -1;
>          }
>      }
>      if (!in_postcopy) {
Peter Xu Jan. 14, 2025, 2:45 p.m. UTC | #2
On Tue, Jan 14, 2025 at 02:48:11PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> ../migration/savevm.c: In function ‘qemu_savevm_state_complete_precopy_non_iterable’:
> ../migration/savevm.c:1560:20: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized]
>  1560 |             return ret;
>       |                    ^~~
> 
> Cc: Peter Xu <peterx@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Peter Xu <peterx@redhat.com>
Marc-André Lureau Jan. 14, 2025, 2:47 p.m. UTC | #3
Hi

On Tue, Jan 14, 2025 at 6:42 PM Fabiano Rosas <farosas@suse.de> wrote:
>
> marcandre.lureau@redhat.com writes:
>
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > ../migration/savevm.c: In function ‘qemu_savevm_state_complete_precopy_non_iterable’:
> > ../migration/savevm.c:1560:20: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized]
> >  1560 |             return ret;
> >       |                    ^~~
>
> Weird that this didn't show up anywhere.

I have a build setup with '--enable-debug' '--enable-asan'
'-Doptimization=g' '-Ddebug=true' for development.

Unfortunately, devs and CI don't seem to run with those flags, we
should probably add it back to CI (apparently partially dropped with
commit cb771ac1). There are regressions to clean up nowadays. Help
welcome!

>
> >
> > Cc: Peter Xu <peterx@redhat.com>
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Reviewed-by: Fabiano Rosas <farosas@suse.de>
>
> > ---
> >  migration/savevm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/migration/savevm.c b/migration/savevm.c
> > index c929da1ca5..6e56d4cf1d 100644
> > --- a/migration/savevm.c
> > +++ b/migration/savevm.c
> > @@ -1557,7 +1557,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
> >              migrate_set_error(ms, local_err);
> >              error_report_err(local_err);
> >              qemu_file_set_error(f, -EFAULT);
> > -            return ret;
> > +            return -1;
> >          }
> >      }
> >      if (!in_postcopy) {
>
Philippe Mathieu-Daudé Jan. 14, 2025, 4:47 p.m. UTC | #4
On 14/1/25 11:48, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> ../migration/savevm.c: In function ‘qemu_savevm_state_complete_precopy_non_iterable’:
> ../migration/savevm.c:1560:20: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized]
>   1560 |             return ret;
>        |                    ^~~
> 
> Cc: Peter Xu <peterx@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   migration/savevm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index c929da1ca5..6e56d4cf1d 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1557,7 +1557,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
>               migrate_set_error(ms, local_err);
>               error_report_err(local_err);
>               qemu_file_set_error(f, -EFAULT);
> -            return ret;
> +            return -1;

Preferably reducing 'ret' scope:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

>           }
>       }
>       if (!in_postcopy) {
diff mbox series

Patch

diff --git a/migration/savevm.c b/migration/savevm.c
index c929da1ca5..6e56d4cf1d 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1557,7 +1557,7 @@  int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
             migrate_set_error(ms, local_err);
             error_report_err(local_err);
             qemu_file_set_error(f, -EFAULT);
-            return ret;
+            return -1;
         }
     }
     if (!in_postcopy) {