mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
qemu-file: Make qemu_fflush() return errors
This let us simplify code of this shape. qemu_fflush(f); int ret = qemu_file_get_error(f); if (ret) { return ret; } into: int ret = qemu_fflush(f); if (ret) { return ret; } I updated all callers where there is any error check. qemu_fclose() don't need to check for f->last_error because qemu_fflush() returns it at the beggining of the function. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Juan Quintela <quintela@redhat.com> Message-ID: <20231025091117.6342-13-quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
@ -305,17 +305,15 @@ int64_t ramblock_recv_bitmap_send(QEMUFile *file,
|
||||
|
||||
qemu_put_be64(file, size);
|
||||
qemu_put_buffer(file, (const uint8_t *)le_bitmap, size);
|
||||
g_free(le_bitmap);
|
||||
/*
|
||||
* Mark as an end, in case the middle part is screwed up due to
|
||||
* some "mysterious" reason.
|
||||
*/
|
||||
qemu_put_be64(file, RAMBLOCK_RECV_BITMAP_ENDING);
|
||||
qemu_fflush(file);
|
||||
|
||||
g_free(le_bitmap);
|
||||
|
||||
if (qemu_file_get_error(file)) {
|
||||
return qemu_file_get_error(file);
|
||||
int ret = qemu_fflush(file);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return size + sizeof(size);
|
||||
@ -2996,9 +2994,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
|
||||
}
|
||||
|
||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
||||
qemu_fflush(f);
|
||||
|
||||
return 0;
|
||||
return qemu_fflush(f);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3118,10 +3114,8 @@ out:
|
||||
}
|
||||
|
||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
||||
qemu_fflush(f);
|
||||
ram_transferred_add(8);
|
||||
|
||||
ret = qemu_file_get_error(f);
|
||||
ret = qemu_fflush(f);
|
||||
}
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
@ -3196,9 +3190,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
|
||||
qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH);
|
||||
}
|
||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
||||
qemu_fflush(f);
|
||||
|
||||
return 0;
|
||||
return qemu_fflush(f);
|
||||
}
|
||||
|
||||
static void ram_state_pending_estimate(void *opaque, uint64_t *must_precopy,
|
||||
|
Reference in New Issue
Block a user