diff options
author | Juan Quintela <quintela@redhat.com> | 2012-08-29 19:14:54 +0200 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2012-10-17 18:34:59 +0200 |
commit | 29eee86f312a7351b0e694e48b435084355630f7 (patch) | |
tree | 62c5631c8625896c7a873ab85b3ad2ae130b29ae /savevm.c | |
parent | 7311bea33fab3bed02e9fca8b36fd6234a3a7cb9 (diff) |
savevm: unfold qemu_fclose_internal()
It was used only one, and was only one if. It makes error handling
saner.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'savevm.c')
-rw-r--r-- | savevm.c | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -506,22 +506,6 @@ static void qemu_fill_buffer(QEMUFile *f) qemu_file_set_error(f, len); } -/** Calls close function and set last_error if needed - * - * Internal function. qemu_fflush() must be called before this. - * - * Returns f->close() return value, or 0 if close function is not set. - */ -static int qemu_fclose_internal(QEMUFile *f) -{ - int ret = 0; - if (f->close) { - ret = f->close(f->opaque); - qemu_file_set_if_error(f, ret); - } - return ret; -} - /** Closes the file * * Returns negative error value if any error happened on previous operations or @@ -532,12 +516,14 @@ static int qemu_fclose_internal(QEMUFile *f) */ int qemu_fclose(QEMUFile *f) { - int ret, ret2; + int ret; ret = qemu_fflush(f); - ret2 = qemu_fclose_internal(f); - if (ret >= 0) { - ret = ret2; + if (f->close) { + int ret2 = f->close(f->opaque); + if (ret >= 0) { + ret = ret2; + } } /* If any error was spotted before closing, we should report it * instead of the close() return value. |