qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>, anthony@codemonkey.ws
Subject: [Qemu-devel] [PATCH 07/49] savevm.c: Coding style fixes
Date: Mon, 13 Jan 2014 18:39:52 +0100	[thread overview]
Message-ID: <1389634834-24181-8-git-send-email-quintela@redhat.com> (raw)
In-Reply-To: <1389634834-24181-1-git-send-email-quintela@redhat.com>

From: Eduardo Habkost <ehabkost@redhat.com>

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 savevm.c | 75 +++++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 44 insertions(+), 31 deletions(-)

diff --git a/savevm.c b/savevm.c
index 3cdd5f2..66b8b5e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -137,14 +137,12 @@ struct QEMUFile {
     int last_error;
 };

-typedef struct QEMUFileStdio
-{
+typedef struct QEMUFileStdio {
     FILE *stdio_file;
     QEMUFile *file;
 } QEMUFileStdio;

-typedef struct QEMUFileSocket
-{
+typedef struct QEMUFileSocket {
     int fd;
     QEMUFile *file;
 } QEMUFileSocket;
@@ -208,7 +206,8 @@ static int stdio_get_fd(void *opaque)
     return fileno(s->stdio_file);
 }

-static int stdio_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size)
+static int stdio_put_buffer(void *opaque, const uint8_t *buf, int64_t pos,
+                            int size)
 {
     QEMUFileStdio *s = opaque;
     return fwrite(buf, 1, size, s->stdio_file);
@@ -310,7 +309,7 @@ QEMUFile *qemu_popen_cmd(const char *command, const char *mode)

     s->stdio_file = stdio_file;

-    if(mode[0] == 'r') {
+    if (mode[0] == 'r') {
         s->file = qemu_fopen_ops(s, &stdio_pipe_read_ops);
     } else {
         s->file = qemu_fopen_ops(s, &stdio_pipe_write_ops);
@@ -429,7 +428,7 @@ QEMUFile *qemu_fdopen(int fd, const char *mode)
     s = g_malloc0(sizeof(QEMUFileSocket));
     s->fd = fd;

-    if(mode[0] == 'r') {
+    if (mode[0] == 'r') {
         s->file = qemu_fopen_ops(s, &unix_read_ops);
     } else {
         s->file = qemu_fopen_ops(s, &unix_write_ops);
@@ -491,10 +490,11 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
     s = g_malloc0(sizeof(QEMUFileStdio));

     s->stdio_file = fopen(filename, mode);
-    if (!s->stdio_file)
+    if (!s->stdio_file) {
         goto fail;
-    
-    if(mode[0] == 'w') {
+    }
+
+    if (mode[0] == 'w') {
         s->file = qemu_fopen_ops(s, &stdio_file_write_ops);
     } else {
         s->file = qemu_fopen_ops(s, &stdio_file_read_ops);
@@ -550,8 +550,9 @@ static const QEMUFileOps bdrv_write_ops = {

 static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
 {
-    if (is_writable)
+    if (is_writable) {
         return qemu_fopen_ops(bs, &bdrv_write_ops);
+    }
     return qemu_fopen_ops(bs, &bdrv_read_ops);
 }

@@ -703,8 +704,9 @@ static void qemu_fill_buffer(QEMUFile *f)
         f->pos += len;
     } else if (len == 0) {
         qemu_file_set_error(f, -EIO);
-    } else if (len != -EAGAIN)
+    } else if (len != -EAGAIN) {
         qemu_file_set_error(f, len);
+    }
 }

 int qemu_get_fd(QEMUFile *f)
@@ -791,8 +793,9 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size)

     while (size > 0) {
         l = IO_BUF_SIZE - f->buf_index;
-        if (l > size)
+        if (l > size) {
             l = size;
+        }
         memcpy(f->buf + f->buf_index, buf, l);
         f->bytes_xfer += l;
         if (f->ops->writev_buffer) {
@@ -1100,8 +1103,9 @@ static int get_int32_equal(QEMUFile *f, void *pv, size_t size)
     int32_t v2;
     qemu_get_sbe32s(f, &v2);

-    if (*v == v2)
+    if (*v == v2) {
         return 0;
+    }
     return -EINVAL;
 }

@@ -1120,8 +1124,9 @@ static int get_int32_le(QEMUFile *f, void *pv, size_t size)
     int32_t new;
     qemu_get_sbe32s(f, &new);

-    if (*old <= new)
+    if (*old <= new) {
         return 0;
+    }
     return -EINVAL;
 }

@@ -1287,8 +1292,9 @@ static int get_uint8_equal(QEMUFile *f, void *pv, size_t size)
     uint8_t v2;
     qemu_get_8s(f, &v2);

-    if (*v == v2)
+    if (*v == v2) {
         return 0;
+    }
     return -EINVAL;
 }

@@ -1307,8 +1313,9 @@ static int get_uint16_equal(QEMUFile *f, void *pv, size_t size)
     uint16_t v2;
     qemu_get_be16s(f, &v2);

-    if (*v == v2)
+    if (*v == v2) {
         return 0;
+    }
     return -EINVAL;
 }

@@ -1502,8 +1509,9 @@ static int calculate_compat_instance_id(const char *idstr)
     int instance_id = 0;

     QTAILQ_FOREACH(se, &savevm_handlers, entry) {
-        if (!se->compat)
+        if (!se->compat) {
             continue;
+        }

         if (strcmp(idstr, se->compat->idstr) == 0
             && instance_id <= se->compat->instance_id) {
@@ -1690,10 +1698,11 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
     }
     if (vmsd->pre_load) {
         int ret = vmsd->pre_load(opaque);
-        if (ret)
+        if (ret) {
             return ret;
+        }
     }
-    while(field->name) {
+    while (field->name) {
         if ((field->field_exists &&
              field->field_exists(opaque, version_id)) ||
             (!field->field_exists &&
@@ -1729,7 +1738,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                     addr = *(void **)addr;
                 }
                 if (field->flags & VMS_STRUCT) {
-                    ret = vmstate_load_state(f, field->vmsd, addr, field->vmsd->version_id);
+                    ret = vmstate_load_state(f, field->vmsd, addr,
+                                             field->vmsd->version_id);
                 } else {
                     ret = field->info->get(f, addr, size);

@@ -1759,7 +1769,7 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
     if (vmsd->pre_save) {
         vmsd->pre_save(opaque);
     }
-    while(field->name) {
+    while (field->name) {
         if (!field->field_exists ||
             field->field_exists(opaque, vmsd->version_id)) {
             void *base_addr = opaque + field->offset;
@@ -1818,7 +1828,7 @@ static void vmstate_save(QEMUFile *f, SaveStateEntry *se)
         se->ops->save_state(f, se->opaque);
         return;
     }
-    vmstate_save_state(f,se->vmsd, se->opaque);
+    vmstate_save_state(f, se->vmsd, se->opaque);
 }

 bool qemu_savevm_state_blocked(Error **errp)
@@ -1846,7 +1856,7 @@ void qemu_savevm_state_begin(QEMUFile *f,
         }
         se->ops->set_params(params, se->opaque);
     }
-    
+
     qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
     qemu_put_be32(f, QEMU_VM_FILE_VERSION);

@@ -2106,7 +2116,7 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id)

 static const VMStateDescription *vmstate_get_subsection(const VMStateSubsection *sub, char *idstr)
 {
-    while(sub && sub->needed) {
+    while (sub && sub->needed) {
         if (strcmp(idstr, sub->vmsd->name) == 0) {
             return sub->vmsd;
         }
@@ -2198,16 +2208,18 @@ int qemu_loadvm_state(QEMUFile *f)
     }

     v = qemu_get_be32(f);
-    if (v != QEMU_VM_FILE_MAGIC)
+    if (v != QEMU_VM_FILE_MAGIC) {
         return -EINVAL;
+    }

     v = qemu_get_be32(f);
     if (v == QEMU_VM_FILE_VERSION_COMPAT) {
         fprintf(stderr, "SaveVM v2 format is obsolete and don't work anymore\n");
         return -ENOTSUP;
     }
-    if (v != QEMU_VM_FILE_VERSION)
+    if (v != QEMU_VM_FILE_VERSION) {
         return -ENOTSUP;
+    }

     while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
         uint32_t instance_id, version_id, section_id;
@@ -2326,8 +2338,7 @@ static int del_existing_snapshots(Monitor *mon, const char *name)
     bs = NULL;
     while ((bs = bdrv_next(bs))) {
         if (bdrv_can_snapshot(bs) &&
-            bdrv_snapshot_find(bs, snapshot, name) >= 0)
-        {
+            bdrv_snapshot_find(bs, snapshot, name) >= 0) {
             bdrv_snapshot_delete_by_id_or_name(bs, name, &err);
             if (error_is_set(&err)) {
                 monitor_printf(mon,
@@ -2437,8 +2448,9 @@ void do_savevm(Monitor *mon, const QDict *qdict)
     }

  the_end:
-    if (saved_vm_running)
+    if (saved_vm_running) {
         vm_start();
+    }
 }

 void qmp_xen_save_devices_state(const char *filename, Error **errp)
@@ -2462,8 +2474,9 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
     }

  the_end:
-    if (saved_vm_running)
+    if (saved_vm_running) {
         vm_start();
+    }
 }

 int load_vmstate(const char *name)
-- 
1.8.4.2

  parent reply	other threads:[~2014-01-13 17:41 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 17:39 [Qemu-devel] [PULL 00/49] migration queue Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 01/49] avoid a bogus COMPLETED->CANCELLED transition Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 02/49] introduce MIG_STATE_CANCELLING state Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 03/49] migration: Fix rate limit Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 04/49] qemu-file: Make a few functions non-static Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 05/49] migration: Move QEMU_VM_* defines to migration/migration.h Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 06/49] savevm: Convert all tabs to spaces Juan Quintela
2014-01-13 17:39 ` Juan Quintela [this message]
2014-01-13 17:39 ` [Qemu-devel] [PATCH 08/49] savevm.c: Coding style fix Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 09/49] vmstate: Move VMState code to vmstate.c Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 10/49] qemu-file: Move QEMUFile code to qemu-file.c Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 11/49] savevm: Small comment about why timer QEMUFile/VMState code is in savevm.c Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 12/49] tests: Some unit tests for vmstate.c Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 13/49] bitmap: use long as index Juan Quintela
2014-01-13 17:39 ` [Qemu-devel] [PATCH 14/49] memory: cpu_physical_memory_set_dirty_flags() result is never used Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 15/49] memory: cpu_physical_memory_set_dirty_range() return void Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 16/49] exec: use accessor function to know if memory is dirty Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 17/49] memory: create function to set a single dirty bit Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 18/49] exec: create function to get " Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 19/49] memory: make cpu_physical_memory_is_dirty return bool Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 20/49] memory: all users of cpu_physical_memory_get_dirty used only one flag Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 21/49] memory: set single dirty flags when possible Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 22/49] memory: cpu_physical_memory_set_dirty_range() always dirty all flags Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 23/49] memory: cpu_physical_memory_mask_dirty_range() always clears a single flag Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 24/49] memory: use bit 2 for migration Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 25/49] memory: make sure that client is always inside range Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 26/49] memory: only resize dirty bitmap when memory size increases Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 27/49] memory: cpu_physical_memory_clear_dirty_flag() result is never used Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 28/49] bitmap: Add bitmap_zero_extend operation Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 29/49] memory: split dirty bitmap into three Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 30/49] memory: unfold cpu_physical_memory_clear_dirty_flag() in its only user Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 31/49] memory: unfold cpu_physical_memory_set_dirty() " Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 32/49] memory: unfold cpu_physical_memory_set_dirty_flag() Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 33/49] memory: make cpu_physical_memory_get_dirty() the main function Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 34/49] memory: cpu_physical_memory_get_dirty() is used as returning a bool Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 35/49] memory: s/mask/clear/ cpu_physical_memory_mask_dirty_range Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 36/49] memory: use find_next_bit() to find dirty bits Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 37/49] memory: cpu_physical_memory_set_dirty_range() now uses bitmap operations Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 38/49] memory: cpu_physical_memory_clear_dirty_range() " Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 39/49] memory: s/dirty/clean/ in cpu_physical_memory_is_dirty() Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 40/49] memory: make cpu_physical_memory_reset_dirty() take a length parameter Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 41/49] memory: cpu_physical_memory_set_dirty_tracking() should return void Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 42/49] memory: split cpu_physical_memory_* functions to its own include Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 43/49] memory: unfold memory_region_test_and_clear() Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 44/49] kvm: use directly cpu_physical_memory_* api for tracking dirty pages Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 45/49] kvm: refactor start address calculation Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 46/49] memory: move bitmap synchronization to its own function Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 47/49] memory: syncronize kvm bitmap using bitmaps operations Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 48/49] ram: split function that synchronizes a range Juan Quintela
2014-01-13 17:40 ` [Qemu-devel] [PATCH 49/49] migration: synchronize memory bitmap 64bits at a time Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389634834-24181-8-git-send-email-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).