Skip to contentSkip to conversation

migration: remove unreachable code after reading data

PATCH In review Daniel P. Berrangé 2 participants 3 messages Jun 27, 2022 – Jul 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 migration: remove unreachable code after reading data

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
---
 migration/qemu-file.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
migration/qemu-file.c +1 -3
index 1e80d496b7..1615c48b7e 100644
@@ -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;
Signature · 1 line
2.36.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · * Daniel P. Berrangé ([email protected]) 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
Quoted 23 lines
---
 migration/qemu-file.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
migration/qemu-file.c +1 -3
index 1e80d496b7..1615c48b7e 100644
@@ -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;
Signature · 1 line
2.36.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#2 lore raw
In reply to Daniel P. Berrangé
Quoted 8 lines · * Daniel P. Berrangé ([email protected]) 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

Queued

Quoted 24 lines
---
 migration/qemu-file.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
migration/qemu-file.c +1 -3
index 1e80d496b7..1615c48b7e 100644
@@ -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;
Signature · 1 line
2.36.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK