All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] migration: remove unreachable code after reading data
@ 2022-06-27 13:53 Daniel P. Berrangé
  2022-06-27 14:22 ` Dr. David Alan Gilbert
  2022-07-19 13:51 ` Dr. David Alan Gilbert
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2022-06-27 13:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dr. David Alan Gilbert, Juan Quintela, Daniel P. Berrangé

The code calls qio_channel_read() in a loop when it reports
QIO_CHANNEL_ERR_BLOCK. This code is reported when errno==EAGAIN.

As such the later block of code will always hit the 'errno != EAGAIN'
condition, making the final 'else' unreachable.

Fixes: Coverity CID 1490203
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 migration/qemu-file.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 1e80d496b7..1615c48b7e 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -384,10 +384,8 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
         f->total_transferred += len;
     } else if (len == 0) {
         qemu_file_set_error_obj(f, -EIO, local_error);
-    } else if (len != -EAGAIN) {
-        qemu_file_set_error_obj(f, len, local_error);
     } else {
-        error_free(local_error);
+        qemu_file_set_error_obj(f, len, local_error);
     }
 
     return len;
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] migration: remove unreachable code after reading data
  2022-06-27 13:53 [PATCH] migration: remove unreachable code after reading data Daniel P. Berrangé
@ 2022-06-27 14:22 ` Dr. David Alan Gilbert
  2022-07-19 13:51 ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2022-06-27 14:22 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: qemu-devel, Juan Quintela

* Daniel P. Berrangé (berrange@redhat.com) wrote:
> The code calls qio_channel_read() in a loop when it reports
> QIO_CHANNEL_ERR_BLOCK. This code is reported when errno==EAGAIN.
> 
> As such the later block of code will always hit the 'errno != EAGAIN'
> condition, making the final 'else' unreachable.
> 
> Fixes: Coverity CID 1490203
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/qemu-file.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/migration/qemu-file.c b/migration/qemu-file.c
> index 1e80d496b7..1615c48b7e 100644
> --- a/migration/qemu-file.c
> +++ b/migration/qemu-file.c
> @@ -384,10 +384,8 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
>          f->total_transferred += len;
>      } else if (len == 0) {
>          qemu_file_set_error_obj(f, -EIO, local_error);
> -    } else if (len != -EAGAIN) {
> -        qemu_file_set_error_obj(f, len, local_error);
>      } else {
> -        error_free(local_error);
> +        qemu_file_set_error_obj(f, len, local_error);
>      }
>  
>      return len;
> -- 
> 2.36.1
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] migration: remove unreachable code after reading data
  2022-06-27 13:53 [PATCH] migration: remove unreachable code after reading data Daniel P. Berrangé
  2022-06-27 14:22 ` Dr. David Alan Gilbert
@ 2022-07-19 13:51 ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2022-07-19 13:51 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: qemu-devel, Juan Quintela

* Daniel P. Berrangé (berrange@redhat.com) wrote:
> The code calls qio_channel_read() in a loop when it reports
> QIO_CHANNEL_ERR_BLOCK. This code is reported when errno==EAGAIN.
> 
> As such the later block of code will always hit the 'errno != EAGAIN'
> condition, making the final 'else' unreachable.
> 
> Fixes: Coverity CID 1490203
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Queued

> ---
>  migration/qemu-file.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/migration/qemu-file.c b/migration/qemu-file.c
> index 1e80d496b7..1615c48b7e 100644
> --- a/migration/qemu-file.c
> +++ b/migration/qemu-file.c
> @@ -384,10 +384,8 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
>          f->total_transferred += len;
>      } else if (len == 0) {
>          qemu_file_set_error_obj(f, -EIO, local_error);
> -    } else if (len != -EAGAIN) {
> -        qemu_file_set_error_obj(f, len, local_error);
>      } else {
> -        error_free(local_error);
> +        qemu_file_set_error_obj(f, len, local_error);
>      }
>  
>      return len;
> -- 
> 2.36.1
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-19 14:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27 13:53 [PATCH] migration: remove unreachable code after reading data Daniel P. Berrangé
2022-06-27 14:22 ` Dr. David Alan Gilbert
2022-07-19 13:51 ` Dr. David Alan Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.