[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH V1] migration: Fixed code style
From: |
Alexey Perevalov |
Subject: |
[Qemu-trivial] [PATCH V1] migration: Fixed code style |
Date: |
Fri, 28 Apr 2017 15:44:52 +0300 |
This patch fixes:
- WARNING: line over 80 characters
- ERROR: do not initialise globals to 0 or NULL
- ERROR: spaces required around that '+' and other ariphmetic
operations
- ERROR: braces {} are necessary for all arms of this statement
and braces of the functions
- ERROR: do not use C99 // comments
Signed-off-by: Alexey Perevalov <address@hidden>
---
migration/exec.c | 3 ++-
migration/migration.c | 6 +++---
migration/postcopy-ram.c | 2 +-
migration/ram.c | 13 ++++++++-----
migration/rdma.c | 23 ++++++++++++++---------
migration/savevm.c | 9 ++++++---
migration/vmstate.c | 10 +++++-----
7 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/migration/exec.c b/migration/exec.c
index 9157721..48fb890 100644
--- a/migration/exec.c
+++ b/migration/exec.c
@@ -25,7 +25,8 @@
#include "trace.h"
-void exec_start_outgoing_migration(MigrationState *s, const char *command,
Error **errp)
+void exec_start_outgoing_migration(MigrationState *s, const char *command,
+ Error **errp)
{
QIOChannel *ioc;
const char *argv[] = { "/bin/sh", "-c", command, NULL };
diff --git a/migration/migration.c b/migration/migration.c
index 353f272..c5a6494 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1472,8 +1472,8 @@ static void migrate_handle_rp_req_pages(MigrationState
*ms, const char* rbname,
* Since we currently insist on matching page sizes, just sanity check
* we're being asked for whole host pages.
*/
- if (start & (our_host_ps-1) ||
- (len & (our_host_ps-1))) {
+ if (start & (our_host_ps - 1) ||
+ (len & (our_host_ps - 1))) {
error_report("%s: Misaligned page request, start: " RAM_ADDR_FMT
" len: %zd", __func__, start, len);
mark_source_rp_bad(ms);
@@ -2021,7 +2021,7 @@ static void *migration_thread(void *opaque)
}
if (qemu_file_rate_limit(s->to_dst_file)) {
/* usleep expects microseconds */
- g_usleep((initial_time + BUFFER_DELAY - current_time)*1000);
+ g_usleep((initial_time + BUFFER_DELAY - current_time) * 1000);
}
}
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 85fd8d7..40acf5e 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -166,7 +166,7 @@ bool postcopy_ram_supported_by_host(void)
strerror(errno));
goto out;
}
- g_assert(((size_t)testarea & (pagesize-1)) == 0);
+ g_assert(((size_t)testarea & (pagesize - 1)) == 0);
reg_struct.range.start = (uintptr_t)testarea;
reg_struct.range.len = pagesize;
diff --git a/migration/ram.c b/migration/ram.c
index f48664e..10fd7c3 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -82,14 +82,16 @@ static uint8_t *xbzrle_decoded_buf;
static void XBZRLE_cache_lock(void)
{
- if (migrate_use_xbzrle())
+ if (migrate_use_xbzrle()) {
qemu_mutex_lock(&XBZRLE.lock);
+ }
}
static void XBZRLE_cache_unlock(void)
{
- if (migrate_use_xbzrle())
+ if (migrate_use_xbzrle()) {
qemu_mutex_unlock(&XBZRLE.lock);
+ }
}
/**
@@ -1258,7 +1260,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t
start, ram_addr_t len)
rs->last_req_rb = ramblock;
}
trace_ram_save_queue_pages(ramblock->idstr, start, len);
- if (start+len > ramblock->used_length) {
+ if (start + len > ramblock->used_length) {
error_report("%s request overrun start=" RAM_ADDR_FMT " len="
RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT,
__func__, start, len, ramblock->used_length);
@@ -2085,7 +2087,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
iterations
*/
if ((i & 63) == 0) {
- uint64_t t1 = (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) /
1000000;
+ uint64_t t1 =
+ (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) / 1000000;
if (t1 > MAX_WAIT) {
trace_ram_save_iterate_big_wait(t1, i);
break;
@@ -2230,7 +2233,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void
*host)
*/
static inline RAMBlock *ram_block_from_stream(QEMUFile *f, int flags)
{
- static RAMBlock *block = NULL;
+ static RAMBlock *block;
char id[256];
uint8_t len;
diff --git a/migration/rdma.c b/migration/rdma.c
index fe0a4b5..9d89456 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -257,7 +257,8 @@ static uint64_t htonll(uint64_t v)
return u.llv;
}
-static uint64_t ntohll(uint64_t v) {
+static uint64_t ntohll(uint64_t v)
+{
union { uint32_t lv[2]; uint64_t llv; } u;
u.llv = v;
return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]);
@@ -586,7 +587,8 @@ static int rdma_add_block(RDMAContext *rdma, const char
*block_name,
block->is_ram_block = local->init ? false : true;
if (rdma->blockmap) {
- g_hash_table_insert(rdma->blockmap, (void *)(uintptr_t)block_offset,
block);
+ g_hash_table_insert(rdma->blockmap, (void *)(uintptr_t)block_offset,
+ block);
}
trace_rdma_add_block(block_name, local->nb_blocks,
@@ -827,7 +829,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context
*verbs, Error **errp)
*/
if (!verbs) {
int num_devices, x;
- struct ibv_device ** dev_list = ibv_get_device_list(&num_devices);
+ struct ibv_device **dev_list = ibv_get_device_list(&num_devices);
bool roce_found = false;
bool ib_found = false;
@@ -1261,7 +1263,7 @@ const char *print_wrid(int wrid)
* workload information or LRU information is available, do not attempt to use
* this feature except for basic testing.
*/
-//#define RDMA_UNREGISTRATION_EXAMPLE
+/*#define RDMA_UNREGISTRATION_EXAMPLE*/
/*
* Perform a non-optimized memory unregistration after every transfer
@@ -3245,7 +3247,8 @@ static int qemu_rdma_registration_handle(QEMUFile *f,
void *opaque)
reg_result = &results[count];
trace_qemu_rdma_registration_handle_register_loop(count,
- reg->current_index, reg->key.current_addr,
reg->chunks);
+ reg->current_index, reg->key.current_addr,
+ reg->chunks);
if (reg->current_index >= rdma->local_ram_blocks.nb_blocks) {
error_report("rdma: 'register' bad block index %u (vs %d)",
@@ -3475,13 +3478,15 @@ static int qemu_rdma_registration_stop(QEMUFile *f,
void *opaque,
/*
* The protocol uses two different sets of rkeys (mutually exclusive):
* 1. One key to represent the virtual address of the entire ram block.
- * (dynamic chunk registration disabled - pin everything with one
rkey.)
+ * (dynamic chunk registration disabled - pin everything with one
+ * rkey.)
* 2. One to represent individual chunks within a ram block.
* (dynamic chunk registration enabled - pin individual chunks.)
*
- * Once the capability is successfully negotiated, the destination
transmits
- * the keys to use (or sends them later) including the virtual
addresses
- * and then propagates the remote ram block descriptions to his local
copy.
+ * Once the capability is successfully negotiated, the destination
+ * transmits the keys to use (or sends them later) including the
+ * virtual addresses and then propagates the remote ram block
+ * descriptions to his local copy.
*/
if (local->nb_blocks != nb_dest_blocks) {
diff --git a/migration/savevm.c b/migration/savevm.c
index 03ae1bd..72e509b 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -732,7 +732,8 @@ static int vmstate_load(QEMUFile *f, SaveStateEntry *se,
int version_id)
return vmstate_load_state(f, se->vmsd, se->opaque, version_id);
}
-static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se, QJSON
*vmdesc)
+static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se,
+ QJSON *vmdesc)
{
int64_t old_offset, size;
@@ -1324,14 +1325,16 @@ static SaveStateEntry *find_se(const char *idstr, int
instance_id)
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (!strcmp(se->idstr, idstr) &&
(instance_id == se->instance_id ||
- instance_id == se->alias_id))
+ instance_id == se->alias_id)) {
return se;
+ }
/* Migrating from an older version? */
if (strstr(se->idstr, idstr) && se->compat) {
if (!strcmp(se->compat->idstr, idstr) &&
(instance_id == se->compat->instance_id ||
- instance_id == se->alias_id))
+ instance_id == se->alias_id)) {
return se;
+ }
}
}
return NULL;
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 7b4a607..d55b05e 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -21,13 +21,13 @@ static int vmstate_n_elems(void *opaque, VMStateField
*field)
if (field->flags & VMS_ARRAY) {
n_elems = field->num;
} else if (field->flags & VMS_VARRAY_INT32) {
- n_elems = *(int32_t *)(opaque+field->num_offset);
+ n_elems = *(int32_t *)(opaque + field->num_offset);
} else if (field->flags & VMS_VARRAY_UINT32) {
- n_elems = *(uint32_t *)(opaque+field->num_offset);
+ n_elems = *(uint32_t *)(opaque + field->num_offset);
} else if (field->flags & VMS_VARRAY_UINT16) {
- n_elems = *(uint16_t *)(opaque+field->num_offset);
+ n_elems = *(uint16_t *)(opaque + field->num_offset);
} else if (field->flags & VMS_VARRAY_UINT8) {
- n_elems = *(uint8_t *)(opaque+field->num_offset);
+ n_elems = *(uint8_t *)(opaque + field->num_offset);
}
if (field->flags & VMS_MULTIPLY_ELEMENTS) {
@@ -43,7 +43,7 @@ static int vmstate_size(void *opaque, VMStateField *field)
int size = field->size;
if (field->flags & VMS_VBUFFER) {
- size = *(int32_t *)(opaque+field->size_offset);
+ size = *(int32_t *)(opaque + field->size_offset);
if (field->flags & VMS_MULTIPLY) {
size *= field->size;
}
--
1.9.1