On 11/01/2011 08:20 PM, Eduardo Habkost wrote:
+/** 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_close(QEMUFile *f)
  {
      int ret = 0;
-    qemu_fflush(f);
-    if (f->close)
+    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
+ * while closing the file. Returns 0 or positive number on success.
+ *
+ * The meaning of return value on success depends on the specific backend
+ * being used.
+ */
+int qemu_fclose(QEMUFile *f)
+{
+    int ret;
+    qemu_fflush(f);
+    ret = qemu_close(f);

Isn't the return value of qemu_close useless, because if nonzero it will always be present in last_error too? With this change, I'd leave it inline.

+    if (f->last_error)
+        ret = f->last_error;
      g_free(f);
      return ret;

Paolo


Reply via email to