[PATCH] plugin: foo * bar should be foo *bar

2021-01-14 Thread chaihaoyu
recently I a code style problem while using checkpatch.pl tool,please review.
foo * bar should be foo *bar:

Signed-off-by: Haoyu Chai 

---
 plugins/api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/api.c b/plugins/api.c
index bbdc5a4eb4..9661824b89 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -309,7 +309,7 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct 
qemu_plugin_hwaddr *haddr
  */

 #ifndef CONFIG_USER_ONLY
-static MachineState * get_ms(void)
+static MachineState *get_ms(void)
 {
 return MACHINE(qdev_get_machine());
 }
-- 
2.29.1.59.gf9b6481aed



[PATCH v2 5/5] softmmu: code indent should never use tabs

2021-01-14 Thread chaihaoyu
This patch fixes error messages found by checkpatch.pl:
code indent should never use tabs

Signed-off-by: Haoyu Chai 

---
 softmmu/physmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 43e37660c7..7aed899e3f 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -3273,7 +3273,7 @@ int64_t address_space_cache_init(MemoryRegionCache *cache,
  * cache->xlat and the end of the section.
  */
 diff = int128_sub(cache->mrs.size,
- int128_make64(cache->xlat - 
cache->mrs.offset_within_region));
+int128_make64(cache->xlat - cache->mrs.offset_within_region));
 l = int128_get64(int128_min(diff, int128_make64(l)));

 mr = cache->mrs.mr;
-- 
2.29.1.59.gf9b6481aed



[PATCH v2 4/5] softmmu: "foo* bar" should be "foo *bar"

2021-01-14 Thread chaihaoyu
This patch fixes error messages found by checkpatch.pl:
"foo* bar" should be "foo *bar"

Signed-off-by: Haoyu Chai 

---
 softmmu/globals.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/softmmu/globals.c b/softmmu/globals.c
index 7d0fc81183..341a7029ff 100644
--- a/softmmu/globals.c
+++ b/softmmu/globals.c
@@ -35,7 +35,7 @@

 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int display_opengl;
-const char* keyboard_layout;
+const char *keyboard_layout;
 bool enable_mlock;
 bool enable_cpu_pm;
 int nb_nics;
-- 
2.29.1.59.gf9b6481aed



[PATCH v2 2/5] softmmu: braces {} are needed for if statement

2021-01-14 Thread chaihaoyu
This patch fixes error messages found by checkpatch.pl:
braces {} are needed for if statement

Signed-off-by: Haoyu Chai 

---
 softmmu/cpus.c |  6 --
 softmmu/dma-helpers.c  |  3 ++-
 softmmu/memory.c   |  3 ++-
 softmmu/physmem.c  | 15 ++-
 softmmu/qdev-monitor.c | 12 
 5 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 1dc20b9dc3..0d16855543 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -744,8 +744,9 @@ void qmp_memsave(int64_t addr, int64_t size, const char 
*filename,

 while (size != 0) {
 l = sizeof(buf);
-if (l > size)
+if (l > size) {
 l = size;
+}
 if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) {
 error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRId64
  " specified", orig_addr, orig_size);
@@ -778,8 +779,9 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char 
*filename,

 while (size != 0) {
 l = sizeof(buf);
-if (l > size)
+if (l > size) {
 l = size;
+}
 cpu_physical_memory_read(addr, buf, l);
 if (fwrite(buf, 1, l, f) != l) {
 error_setg(errp, QERR_IO_ERROR);
diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c
index 29001b5459..ccea3a7750 100644
--- a/softmmu/dma-helpers.c
+++ b/softmmu/dma-helpers.c
@@ -165,8 +165,9 @@ static void dma_blk_cb(void *opaque, int ret)
 }
 }
 }
-if (!mem)
+if (!mem) {
 break;
+}
 qemu_iovec_add(>iov, mem, cur_len);
 dbs->sg_cur_byte += cur_len;
 if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) {
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 2d346b9de4..0ff81def99 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -671,8 +671,9 @@ void flatview_for_each_range(FlatView *fv, flatview_cb cb , 
void *opaque)
 assert(cb);

 FOR_EACH_FLAT_RANGE(fr, fv) {
-if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque))
+if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque)) {
 break;
+}
 }
 }

diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 6301f4f0a5..43e37660c7 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -797,8 +797,9 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr 
len,
 tlb_flush(cpu);
 }

-if (watchpoint)
+if (watchpoint) {
 *watchpoint = wp;
+}
 return 0;
 }

@@ -1210,8 +1211,9 @@ void flatview_add_to_dispatch(FlatView *fv, 
MemoryRegionSection *section)

 void qemu_flush_coalesced_mmio_buffer(void)
 {
-if (kvm_enabled())
+if (kvm_enabled()) {
 kvm_flush_coalesced_mmio_buffer();
+}
 }

 void qemu_mutex_lock_ramlist(void)
@@ -2495,8 +2497,9 @@ static int subpage_register(subpage_t *mmio, uint32_t 
start, uint32_t end,
 {
 int idx, eidx;

-if (start >= TARGET_PAGE_SIZE || end >= TARGET_PAGE_SIZE)
+if (start >= TARGET_PAGE_SIZE || end >= TARGET_PAGE_SIZE) {
 return -1;
+}
 idx = SUBPAGE_IDX(start);
 eidx = SUBPAGE_IDX(end);
 #if defined(DEBUG_SUBPAGE)
@@ -3410,11 +3413,13 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong 
addr,
 phys_addr = cpu_get_phys_page_attrs_debug(cpu, page, );
 asidx = cpu_asidx_from_attrs(cpu, attrs);
 /* if no physical page mapped, return an error */
-if (phys_addr == -1)
+if (phys_addr == -1) {
 return -1;
+}
 l = (page + TARGET_PAGE_SIZE) - addr;
-if (l > len)
+if (l > len) {
 l = len;
+}
 phys_addr += (addr & ~TARGET_PAGE_MASK);
 if (is_write) {
 res = address_space_write_rom(cpu->cpu_ases[asidx].as, phys_addr,
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index a681d6a4e8..8642b2a208 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -182,10 +182,12 @@ static int set_property(void *opaque, const char *name, 
const char *value,
 {
 Object *obj = opaque;

-if (strcmp(name, "driver") == 0)
+if (strcmp(name, "driver") == 0) {
 return 0;
-if (strcmp(name, "bus") == 0)
+}
+if (strcmp(name, "bus") == 0) {
 return 0;
+}

 if (!object_property_parse(obj, name, value, errp)) {
 return -1;
@@ -683,8 +685,9 @@ static void qbus_print(Monitor *mon, BusState *bus, int 
indent);
 static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
  int indent)
 {
-if (!props)
+if (!props) {
 return;
+}
 for (; props->name; props++) {
 char *value;
 char *legacy_name = g_strdup_printf("legacy-%s", props->name);
@@ -769,8 +772,9 @@ static void qbus_print(Monitor *mon, BusState *bus, int 
indent)

 void hmp_info_qtree(Monitor *mon, const QDict *qdict)
 {
-if (sysbus_get_default())
+ 

[PATCH v2 3/5] softmmu: don't use '#' flag of printf format ('%#') in format strings

2021-01-14 Thread chaihaoyu
This patch fixes error messages found by checkpatch.pl:
don't use '#' flag of printf format ('%#') in format strings

Signed-off-by: Haoyu Chai 

---
 softmmu/device_tree.c | 2 +-
 softmmu/runstate.c| 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c
index b9a3ddc518..f1f4fd6f0d 100644
--- a/softmmu/device_tree.c
+++ b/softmmu/device_tree.c
@@ -367,7 +367,7 @@ int qemu_fdt_setprop_cell(void *fdt, const char *node_path,

 r = fdt_setprop_cell(fdt, findnode_nofail(fdt, node_path), property, val);
 if (r < 0) {
-error_report("%s: Couldn't set %s/%s = %#08x: %s", __func__,
+error_report("%s: Couldn't set %s/%s = 0x%08x: %s", __func__,
  node_path, property, val, fdt_strerror(r));
 exit(1);
 }
diff --git a/softmmu/runstate.c b/softmmu/runstate.c
index 636aab0add..87ce18282b 100644
--- a/softmmu/runstate.c
+++ b/softmmu/runstate.c
@@ -490,8 +490,8 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)

 if (info) {
 if (info->type == GUEST_PANIC_INFORMATION_TYPE_HYPER_V) {
-qemu_log_mask(LOG_GUEST_ERROR, "\nHV crash parameters: (%#"PRIx64
-  " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n",
+qemu_log_mask(LOG_GUEST_ERROR, "\nHV crash parameters: (0x%"PRIx64
+  " 0x%"PRIx64" 0x%"PRIx64" 0x%"PRIx64" 
0x%"PRIx64")\n",
   info->u.hyper_v.arg1,
   info->u.hyper_v.arg2,
   info->u.hyper_v.arg3,
-- 
2.29.1.59.gf9b6481aed




[PATCH v2 1/5] softmmu: fix problems about spaces

2021-01-14 Thread chaihaoyu
This patch fixes error messages found by checkpatch.pl:
fix problems about spaces:

Signed-off-by: Haoyu Chai 

---
 softmmu/bootdevice.c   |  4 ++--
 softmmu/memory.c   | 16 
 softmmu/qdev-monitor.c |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/softmmu/bootdevice.c b/softmmu/bootdevice.c
index add4e3d2d1..4edb80de8c 100644
--- a/softmmu/bootdevice.c
+++ b/softmmu/bootdevice.c
@@ -257,7 +257,7 @@ char *get_boot_devices_list(size_t *size)
 bootpath = get_boot_device_path(i->dev, ignore_suffixes, i->suffix);

 if (total) {
-list[total-1] = '\n';
+list[total - 1] = '\n';
 }
 len = strlen(bootpath) + 1;
 list = g_realloc(list, total + len);
@@ -269,7 +269,7 @@ char *get_boot_devices_list(size_t *size)
 *size = total;

 if (boot_strict && *size > 0) {
-list[total-1] = '\n';
+list[total - 1] = '\n';
 list = g_realloc(list, total + 5);
 memcpy([total], "HALT", 5);
 *size = total + 5;
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 333e1ed7b0..2d346b9de4 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -336,7 +336,7 @@ static void flatview_simplify(FlatView *view)
 while (i < view->nr) {
 j = i + 1;
 while (j < view->nr
-   && can_merge(>ranges[j-1], >ranges[j])) {
+   && can_merge(>ranges[j - 1], >ranges[j])) {
 int128_addto(>ranges[i].addr.size, 
view->ranges[j].addr.size);
 ++j;
 }
@@ -841,8 +841,8 @@ static void address_space_update_ioeventfds(AddressSpace 
*as)
 ioeventfds = g_realloc(ioeventfds,
 ioeventfd_max * sizeof(*ioeventfds));
 }
-ioeventfds[ioeventfd_nb-1] = fr->mr->ioeventfds[i];
-ioeventfds[ioeventfd_nb-1].addr = tmp;
+ioeventfds[ioeventfd_nb - 1] = fr->mr->ioeventfds[i];
+ioeventfds[ioeventfd_nb - 1].addr = tmp;
 }
 }
 }
@@ -2371,8 +2371,8 @@ void memory_region_add_eventfd(MemoryRegion *mr,
 ++mr->ioeventfd_nb;
 mr->ioeventfds = g_realloc(mr->ioeventfds,
   sizeof(*mr->ioeventfds) * mr->ioeventfd_nb);
-memmove(>ioeventfds[i+1], >ioeventfds[i],
-sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb-1 - i));
+memmove(>ioeventfds[i + 1], >ioeventfds[i],
+sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - 1 - i));
 mr->ioeventfds[i] = mrfd;
 ioeventfd_update_pending |= mr->enabled;
 memory_region_transaction_commit();
@@ -2404,11 +2404,11 @@ void memory_region_del_eventfd(MemoryRegion *mr,
 }
 }
 assert(i != mr->ioeventfd_nb);
-memmove(>ioeventfds[i], >ioeventfds[i+1],
-sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i+1)));
+memmove(>ioeventfds[i], >ioeventfds[i + 1],
+sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i + 1)));
 --mr->ioeventfd_nb;
 mr->ioeventfds = g_realloc(mr->ioeventfds,
-  sizeof(*mr->ioeventfds)*mr->ioeventfd_nb + 
1);
+  sizeof(*mr->ioeventfds) * mr->ioeventfd_nb + 
1);
 ioeventfd_update_pending |= mr->enabled;
 memory_region_transaction_commit();
 }
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 8dc656becc..a681d6a4e8 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -501,7 +501,7 @@ static BusState *qbus_find(const char *path, Error **errp)
 }

 /* find device */
-if (sscanf(path+pos, "%127[^/]%n", elem, ) != 1) {
+if (sscanf(path + pos, "%127[^/]%n", elem, ) != 1) {
 g_assert_not_reached();
 elem[0] = len = 0;
 }
@@ -536,7 +536,7 @@ static BusState *qbus_find(const char *path, Error **errp)
 }

 /* find bus */
-if (sscanf(path+pos, "%127[^/]%n", elem, ) != 1) {
+if (sscanf(path + pos, "%127[^/]%n", elem, ) != 1) {
 g_assert_not_reached();
 elem[0] = len = 0;
 }
-- 
2.29.1.59.gf9b6481aed



[PATCH v2 0/5] softmmu: some space-style problems while coding

2021-01-14 Thread chaihaoyu
recently I found some code style problems while using checkpatch.pl tool,please 
review.

Haoyu Chai (5):
 softmmu: add spaces around operator
 softmmu: braces {} are needed for if statement
 softmmu: don't use '#' flag of printf format ('%#') in format strings
 softmmu: "foo* bar" should be "foo *bar"
 softmmu: code indent should never use tabs

 softmmu/bootdevice.c   |  4 ++--
 softmmu/cpus.c |  6 --
 softmmu/device_tree.c  |  2 +-
 softmmu/dma-helpers.c  |  3 ++-
 softmmu/globals.c  |  2 +-
 softmmu/memory.c   | 19 ++-
 softmmu/physmem.c  | 17 +++--
 softmmu/qdev-monitor.c | 16 ++--
 softmmu/runstate.c |  4 ++--
 9 files changed, 43 insertions(+), 30 deletions(-)

-- 
2.29.1.59.gf9b6481aed



[PATCH v1 2/3]block: braces {} are necessary for all arms of this statement

2020-12-17 Thread chaihaoyu
This patch fixes error style problems found by checkpatch.pl, please review:
braces {} are necessary for all arms of this statement

Signed-off-by: Haoyu Chai

---
 block/bochs.c|  6 ++-
 block/commit.c   |  3 +-
 block/curl.c | 15 +++--
 block/file-posix.c   | 27 ++---
 block/file-win32.c   | 17 --
 block/qcow2.c| 3 +-
 6 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/block/bochs.c b/block/bochs.c
index 2f010ab40a..ff9d48162e 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -83,8 +83,9 @@ static int bochs_probe(const uint8_t *buf, int buf_size, 
const char *filename)
 {
 const struct bochs_header *bochs = (const void *)buf;

-if (buf_size < HEADER_SIZE)
+if (buf_size < HEADER_SIZE) {
 return 0;
+}

 if (!strcmp(bochs->magic, HEADER_MAGIC) &&
 !strcmp(bochs->type, REDOLOG_TYPE) &&
@@ -156,8 +157,9 @@ static int bochs_open(BlockDriverState *bs, QDict *options, 
int flags,
 goto fail;
 }

-for (i = 0; i < s->catalog_size; i++)
+for (i = 0; i < s->catalog_size; i++) {
 le32_to_cpus(>catalog_bitmap[i]);
+}

 s->data_offset = le32_to_cpu(bochs.header) + (s->catalog_size * 4);
diff --git a/block/commit.c b/block/commit.c
index 1e85c306cc..727037a5d0 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -439,8 +439,9 @@ int bdrv_commit(BlockDriverState *bs)
 uint8_t *buf = NULL;
 Error *local_err = NULL;

-if (!drv)
+if (!drv) {
 return -ENOMEDIUM;
+}

 backing_file_bs = bdrv_cow_bs(bs);
diff --git a/block/curl.c b/block/curl.c
index 4f907c47be..d2d8d5d94b 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -282,15 +281,17 @@ static bool curl_find_buf(BDRVCURLState *s, uint64_t 
start, uint64_t len,
 uint64_t clamped_end = MIN(end, s->len);
 uint64_t clamped_len = clamped_end - start;

-if (!state->orig_buf)
+if (!state->orig_buf) {
 continue;
-if (!state->buf_off)
+}
+if (!state->buf_off) {
 continue;
+}

 // Does the existing buffer cover our section?
 if ((start >= state->buf_start) &&
@@ -344,8 +345,9 @@ static void curl_multi_check_completion(BDRVCURLState *s)
 msg = curl_multi_info_read(s->multi, _in_queue);

 /* Quit when there are no more completions */
-if (!msg)
+if (!msg) {
 break;
+}

 if (msg->msg == CURLMSG_DONE) {
 int i;
@@ -538,8 +540,9 @@ static void curl_clean_state(CURLState *s)
 assert(!s->acb[j]);
 }

-if (s->s->multi)
+if (s->s->multi) {
 curl_multi_remove_handle(s->s->multi, s->curl);
+}

 while (!QLIST_EMPTY(>sockets)) {
 CURLSocket *socket = QLIST_FIRST(>sockets);
@@ -791,8 +794,9 @@ static int curl_open(BlockDriverState *bs, QDict *options, 
int flags,
 curl_easy_setopt(state->curl, CURLOPT_HEADERFUNCTION,
  curl_header_cb);
 curl_easy_setopt(state->curl, CURLOPT_HEADERDATA, s);
-if (curl_easy_perform(state->curl))
+if (curl_easy_perform(state->curl)) {
 goto out;
+}
 if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, )) {
 goto out;
 }
diff --git a/block/file-posix.c b/block/file-posix.c
index c63926d592..7b9990e02a 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1978,8 +1978,9 @@ static int coroutine_fn raw_co_prw(BlockDriverState *bs, 
uint64_t offset,
 BDRVRawState *s = bs->opaque;
 RawPosixAIOData acb;

-if (fd_open(bs) < 0)
+if (fd_open(bs) < 0) {
 return -EIO;
+}

 /*
  * When using O_DIRECT, the request must be aligned to be able to use
@@ -2206,17 +2207,20 @@ static int64_t raw_getlength(BlockDriverState *bs)
 int fd = s->fd;
 struct stat st;

-if (fstat(fd, ))
+if (fstat(fd, )) {
 return -errno;
+}
 if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
 struct disklabel dl;

-if (ioctl(fd, DIOCGDINFO, ))
+if (ioctl(fd, DIOCGDINFO, )) {
 return -errno;
+}
 return (uint64_t)dl.d_secsize *
 dl.d_partitions[DISKPART(st.st_rdev)].p_size;
-} else
+} else {
 return st.st_size;
+}
 }
 #elif defined(__NetBSD__)
 static int64_t raw_getlength(BlockDriverState *bs)
@@ -2225,8 +2229,9 @@ static int64_t raw_getlength(BlockDriverState *bs)
 int fd = s->fd;
 struct stat st;

-if (fstat(fd, ))
+if (fstat(fd, )) {
 return -errno;
+}
 if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
 struct dkwedge_info dkw;

@@ -2235,13 +2240,15 @@ static int64_t raw_getlength(BlockDriverState *bs)
 } else {
 struct disklabel dl;

-if (ioctl(fd, DIOCGDINFO, ))
+if (ioctl(fd, DIOCGDINFO, )) {
 return -errno;
+}
 return (uint64_t)dl.d_secsize *
 

[PATCH v1 3/3] block: "(foo*)" should be "(foo *)"

2020-12-17 Thread chaihaoyu
This patch fixes error style problems found by checkpatch.pl, please review:
"(foo*)" should be "(foo *)"

Signed-off-by: Haoyu Chai

---
 block/curl.c |  2 +-
 block/file-win32.c   |  2 +-
 block/qcow2.c| 10 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/block/curl.c b/block/curl.c
index 4f907c47be..d2d8d5d94b 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -251,7 +250,7 @@ static size_t curl_header_cb(void *ptr, size_t size, size_t 
nmemb, void *opaque)
 /* Called from curl_multi_do_locked, with s->mutex held.  */
 static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
 {
-CURLState *s = ((CURLState*)opaque);
+CURLState *s = ((CURLState *)opaque);
 size_t realsize = size * nmemb;

 trace_curl_read_cb(realsize);
diff --git a/block/file-win32.c b/block/file-win32.c
index 2642088bd6..e3cca0fede 100644
--- a/block/file-win32.c
+++ b/block/file-win32.c
@@ -557,7 +560,7 @@ static int64_t raw_getlength(BlockDriverState *bs)
 static int64_t raw_get_allocated_file_size(BlockDriverState *bs)
 {
 typedef DWORD (WINAPI * get_compressed_t)(const char *filename,
-  DWORD * high);
+  DWORD *high);
 get_compressed_t get_compressed;
 struct _stati64 st;
 const char *filename = bs->filename;
diff --git a/block/qcow2.c b/block/qcow2.c
index b6cb4db8bb..2a06d70f2f 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -269,7 +270,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, 
uint64_t start_offset,

 case QCOW2_EXT_MAGIC_FEATURE_TABLE:
 if (p_feature_table != NULL) {
-void* feature_table = g_malloc0(ext.len + 2 * 
sizeof(Qcow2Feature));
+void *feature_table = g_malloc0(ext.len + 2 * 
sizeof(Qcow2Feature));
 ret = bdrv_pread(bs->file, offset , feature_table, ext.len);
 if (ret < 0) {
 error_setg_errno(errp, -ret, "ERROR: ext_feature_table: "
@@ -2748,7 +2749,7 @@ static void coroutine_fn 
qcow2_co_invalidate_cache(BlockDriverState *bs,
 static size_t header_ext_add(char *buf, uint32_t magic, const void *s,
 size_t len, size_t buflen)
 {
-QCowExtension *ext_backing_fmt = (QCowExtension*) buf;
+QCowExtension *ext_backing_fmt = (QCowExtension *) buf;
 size_t ext_len = sizeof(QCowExtension) + ((len + 7) & ~7);

 if (buflen < ext_len) {
@@ -2790,7 +2791,7 @@ int qcow2_update_header(BlockDriverState *bs)
 buf = qemu_blockalign(bs, buflen);

 /* Header structure */
-header = (QCowHeader*) buf;
+header = (QCowHeader *) buf;

 if (buflen < sizeof(*header)) {
 ret = -ENOSPC;
@@ -3015,7 +3016,7 @@ int qcow2_update_header(BlockDriverState *bs)
 /* Using strncpy is ok here, since buf is not NUL-terminated. */
 strncpy(buf, s->image_backing_file, buflen);

-header->backing_file_offset = cpu_to_be64(buf - ((char*) header));
+header->backing_file_offset = cpu_to_be64(buf - ((char *) header));
 header->backing_file_size   = cpu_to_be32(backing_file_len);
 }

@@ -3374,7 +3375,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, 
Error **errp)
 size_t cluster_size;
 int version;
 int refcount_order;
-uint64_t* refcount_table;
+uint64_t *refcount_table;
 int ret;
 uint8_t compression_type = QCOW2_COMPRESSION_TYPE_ZLIB;



[PATCH v1 1/3] some space-style errors while coding

2020-12-17 Thread chaihaoyu
This patch fixes error style problems found by checkpatch.pl, please review:
some space-style errors while coding

Signed-off-by: Haoyu Chai

---
 block/bochs.c| 10 
 block/cloop.c|  2 +-
 block/curl.c |  7 +++
 block/dmg.c  |  4 +-
 block/file-posix.c   | 13 +-
 block/file-win32.c   | 24 
 block/parallels.c| 10 +++---
 block/qcow2.c| 2 +-
 softmmu/bootdevice.c |  4 +--
 9 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/block/bochs.c b/block/bochs.c
index 2f010ab40a..ff9d48162e 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -293,14 +295,14 @@ static void bochs_close(BlockDriverState *bs)
 }
 static BlockDriver bdrv_bochs = {
-.format_name   = "bochs",
-.instance_size = sizeof(BDRVBochsState),
-.bdrv_probe= bochs_probe,
-.bdrv_open = bochs_open,
+.format_name= "bochs",
+.instance_size  = sizeof(BDRVBochsState),
+.bdrv_probe= bochs_probe,
+.bdrv_open  = bochs_open,
 .bdrv_child_perm = bdrv_default_perms,
 .bdrv_refresh_limits = bochs_refresh_limits,
 .bdrv_co_preadv = bochs_co_preadv,
-.bdrv_close= bochs_close,
+.bdrv_close  = bochs_close,
 .is_format  = true,
 };
diff --git a/block/cloop.c b/block/cloop.c
index c99192a57f..e872caedb3 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -195,7 +195,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, 
int flags,
 }
 s->current_block = s->n_blocks;

-s->sectors_per_block = s->block_size/512;
+s->sectors_per_block = s->block_size / 512;
 bs->total_sectors = s->n_blocks * s->sectors_per_block;
 qemu_co_mutex_init(>lock);
 return 0;
diff --git a/block/curl.c b/block/curl.c
index 4f907c47be..d2d8d5d94b 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -102,8 +102,7 @@ typedef struct CURLSocket {
 QLIST_ENTRY(CURLSocket) next;
 } CURLSocket;

-typedef struct CURLState
-{
+typedef struct CURLState {
 struct BDRVCURLState *s;
 CURLAIOCB *acb[CURL_NUM_ACB];
 CURL *curl;
@@ -282,15 +281,17 @@ static bool curl_find_buf(BDRVCURLState *s, uint64_t 
start, uint64_t len,
 uint64_t clamped_end = MIN(end, s->len);
 uint64_t clamped_len = clamped_end - start;

-for (i=0; istates[i];
 uint64_t buf_end = (state->buf_start + state->buf_off);
 uint64_t buf_fend = (state->buf_start + state->buf_len);
@@ -320,7 +321,7 @@ static bool curl_find_buf(BDRVCURLState *s, uint64_t start, 
uint64_t len,
 acb->start = start - state->buf_start;
 acb->end = acb->start + clamped_len;

-for (j=0; jacb[j]) {
 state->acb[j] = acb;
 return true;
diff --git a/block/dmg.c b/block/dmg.c
index 0d6c317296..b0db135398 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -177,8 +177,8 @@ static int64_t dmg_find_koly_offset(BdrvChild *file, Error 
**errp)
 return ret;
 }
 for (i = 0; i < length - 3; i++) {
-if (buffer[i] == 'k' && buffer[i+1] == 'o' &&
-buffer[i+2] == 'l' && buffer[i+3] == 'y') {
+if (buffer[i] == 'k' && buffer[i + 1] == 'o' &&
+buffer[i + 2] == 'l' && buffer[i + 3] == 'y') {
 return offset + i;
 }
 }
diff --git a/block/file-posix.c b/block/file-posix.c
index c63926d592..7b9990e02a 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -79,7 +79,7 @@
 #if defined(CONFIG_FALLOCATE_PUNCH_HOLE) || 
defined(CONFIG_FALLOCATE_ZERO_RANGE)
 #include 
 #endif
-#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include 
 #include 
 #endif
@@ -125,7 +125,7 @@
 #define FTYPE_FILE   0
 #define FTYPE_CD 1

-#define MAX_BLOCKSIZE  4096
+#define MAX_BLOCKSIZE4096

 /* Posix file locking bytes. Libvirt takes byte 0, we start from higher bytes,
  * leaving a few more bytes for its future use. */
@@ -2281,16 +2288,17 @@ static int64_t raw_getlength(BlockDriverState *bs)
 int fd = s->fd;
 int64_t size;
 struct stat sb;
-#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 int reopened = 0;
 #endif
 int ret;
-#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 again:
 #endif
 if (!fstat(fd, ) && (S_IFCHR & sb.st_mode)) {
@@ -2328,11 +2337,12 @@ again:
 }
 #endif
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-switch(s->type) {
+switch (s->type) {
 case FTYPE_CD:
 /* XXX FreeBSD acd returns UINT_MAX sectors for an empty drive */
-if (size == 2048LL * (unsigned)-1)
+if (size == 2048LL * (unsigned)-1) {
 size = 0;
+}
 /* XXX no disc?  maybe we need to reopen... */
 if (size <= 0 && 

[PATCH v1 0/3] Fix some style problems in block

2020-12-17 Thread chaihaoyu
This patch fixed some code style problems while using checkpatch.pl tool, 
please review.

Date: Wen, 16 Dec 2020 17:19:37 +0800
Subject: [PATCH] Fix some style problems in block
signed-off-by: Haoyu Chai
---

Haoyu Chai (3):
  block: some space-style errors while coding
  block: braces {} are necessary for all arms of this statement
  block: "(foo*)" should be "(foo *)"
---
 block/bochs.c| 16 +-
 block/cloop.c|  2 +-
 block/commit.c   |  3 +-
 block/curl.c | 24 +--
 block/dmg.c  |  4 +-
 block/file-posix.c   | 72 +---
 block/file-win32.c   | 42 ++
 block/parallels.c| 12 
 block/qcow2.c| 15 -
 softmmu/bootdevice.c |  4 +--
 10 files changed, 108 insertions(+), 86 deletions(-)



Re: [PATCH v2 1/3] softmmu: Do not use C99 // comments

2020-11-03 Thread chaihaoyu


Thank you for your replay. That's OK if C99 support both kinds of comment style.


> chaihaoyu  writes:
> 
>> Hi, recently I found some code style problems while using checkpatch.pl 
>> tool,please review.
>>
>> Date: Tue, 3 Nov 2020 11:01:40 +0800
>> signed-off-by: Haoyu Chai
>> ---
>>  softmmu/memory.c | 2 +-
>>  softmmu/memory_mapping.c | 2 +-
>>  softmmu/physmem.c| 2 +-
>>  3 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/softmmu/memory.c b/softmmu/memory.c
>> index 107ce0a4f8..5fb591b001 100644
>> --- a/softmmu/memory.c
>> +++ b/softmmu/memory.c
>> @@ -36,7 +36,7 @@
>>  #include "hw/boards.h"
>>  #include "migration/vmstate.h"
>>
>> -//#define DEBUG_UNASSIGNED
>> +/* #define DEBUG_UNASSIGNED */
>>
>>  static unsigned memory_region_transaction_depth;
>>  static bool memory_region_update_pending;
>> diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
>> index 18d0b8067c..f64053499e 100644
>> --- a/softmmu/memory_mapping.c
>> +++ b/softmmu/memory_mapping.c
>> @@ -19,7 +19,7 @@
>>  #include "exec/memory.h"
>>  #include "exec/address-spaces.h"
>>
>> -//#define DEBUG_GUEST_PHYS_REGION_ADD
>> +/* #define DEBUG_GUEST_PHYS_REGION_ADD */
>>
>>  static void memory_mapping_list_add_mapping_sorted(MemoryMappingList *list,
>> MemoryMapping *mapping)
>> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
>> index 44ffb60b5d..78c1b6580a 100644
>> --- a/softmmu/physmem.c
>> +++ b/softmmu/physmem.c
>> @@ -75,7 +75,7 @@
>>  #include 
>>  #endif
>>
>> -//#define DEBUG_SUBPAGE
>> +/* #define DEBUG_SUBPAGE */
>>
>>  /* ram_list is read under rcu_read_lock()/rcu_read_unlock().  Writes
>>   * are protected by the ramlist lock.
> 
> I recommend to leave these alone.
> 
> CODING_STYLE.rst:
> 
> Rationale: The // form is valid in C99, so this is purely a matter of
> consistency of style. The checkpatch script will warn you about this.
> 
> For "real" comments, we overwhelmingly use /* */, and avoiding // makes
> sense.  Most exceptions are in code we copy from elsewhere, such as
> disas/libvixl/.
> 
> For commenting out *code*, we use both forms.  Here are the counts for
> commenting out macro definitions:
> 
> $ git-grep '^/\* *# *define' | wc -l
> 125
> $ git-grep '^// *# *define' | wc -l
> 192
> 
> .
> 



[PATCH v2 0/3] softmmu: some space-style problems while coding

2020-11-02 Thread chaihaoyu


Hi, recently I found some code style problems while using checkpatch.pl 
tool,please review.

Date: Tue, 3 Nov 2020 11:19:37 +0800
Subject: [PATCH] space style
signed-off-by: Haoyu Chai
---
 softmmu/physmem.c  |  2 +-
 softmmu/qdev-monitor.c |  4 ++--
 softmmu/vl.c   | 12 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 78c1b6580a..44b068ee85 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -3457,7 +3457,7 @@ int qemu_target_page_bits_min(void)

 bool cpu_physical_memory_is_io(hwaddr phys_addr)
 {
-MemoryRegion*mr;
+MemoryRegion *mr;
 hwaddr l = 1;
 bool res;

diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index e283d9c9c0..c2b218adce 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -500,7 +500,7 @@ static BusState *qbus_find(const char *path, Error **errp)
 }

 /* find device */
-if (sscanf(path+pos, "%127[^/]%n", elem, ) != 1) {
+if (sscanf(path + pos, "%127[^/]%n", elem, ) != 1) {
 g_assert_not_reached();
 elem[0] = len = 0;
 }
@@ -535,7 +535,7 @@ static BusState *qbus_find(const char *path, Error **errp)
 }

 /* find bus */
-if (sscanf(path+pos, "%127[^/]%n", elem, ) != 1) {
+if (sscanf(path + pos, "%127[^/]%n", elem, ) != 1) {
 g_assert_not_reached();
 elem[0] = len = 0;
 }
diff --git a/softmmu/vl.c b/softmmu/vl.c
index c4667d91fe..d37520a356 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2418,7 +2418,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
 r++;
 }
 popt = qemu_options;
-for(;;) {
+for (;;) {
 if (!popt->name) {
 error_report("invalid option");
 exit(1);
@@ -3008,7 +3008,7 @@ void qemu_init(int argc, char **argv, char **envp)

 /* second pass of option parsing */
 optind = 1;
-for(;;) {
+for (;;) {
 if (optind >= argc) {
 break;
 }
@@ -3023,7 +3023,7 @@ void qemu_init(int argc, char **argv, char **envp)
 error_report("Option not supported for this target");
 exit(1);
 }
-switch(popt->index) {
+switch (popt->index) {
 case QEMU_OPTION_cpu:
 /* hw initialization will check this */
 cpu_option = optarg;
@@ -3182,13 +3182,13 @@ void qemu_init(int argc, char **argv, char **envp)
 #endif
 case QEMU_OPTION_audio_help:
 audio_legacy_help();
-exit (0);
+exit(0);
 break;
 case QEMU_OPTION_audiodev:
 audio_parse_option(optarg);
 break;
 case QEMU_OPTION_soundhw:
-select_soundhw (optarg);
+select_soundhw(optarg);
 break;
 case QEMU_OPTION_h:
 help(0);
@@ -4323,7 +4323,7 @@ void qemu_init(int argc, char **argv, char **envp)
 if (watchdog) {
 i = select_watchdog(watchdog);
 if (i > 0)
-exit (i == 1 ? 1 : 0);
+exit(i == 1 ? 1 : 0);
 }

 /* This checkpoint is required by replay to separate prior clock
-- 



[PATCH v2 3/3] softmmu: braces {} are necessary for all arms of this statement

2020-11-02 Thread chaihaoyu
Hi, recently I found some code style problems while using checkpatch.pl 
tool,please review.

Date: Tue, 3 Nov 2020 10:09:34 +0800
Subject: [PATCH] braces {} are necessary for all arms of this statement
signed-off-by: Haoyu Chai
---
---
 softmmu/cpus.c |  6 --
 softmmu/dma-helpers.c  |  3 ++-
 softmmu/memory.c   |  3 ++-
 softmmu/physmem.c  | 15 -
 softmmu/qdev-monitor.c | 15 +++--
 softmmu/vl.c   | 49 +++---
 6 files changed, 59 insertions(+), 32 deletions(-)

diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index e46ac68ad0..3e08a64d6b 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -743,8 +743,9 @@ void qmp_memsave(int64_t addr, int64_t size, const char 
*filename,

 while (size != 0) {
 l = sizeof(buf);
-if (l > size)
+if (l > size) {
 l = size;
+}
 if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) {
 error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRId64
  " specified", orig_addr, orig_size);
@@ -777,8 +778,9 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char 
*filename,

 while (size != 0) {
 l = sizeof(buf);
-if (l > size)
+if (l > size) {
 l = size;
+}
 cpu_physical_memory_read(addr, buf, l);
 if (fwrite(buf, 1, l, f) != l) {
 error_setg(errp, QERR_IO_ERROR);
diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c
index 03c92e0cc6..9194ebf681 100644
--- a/softmmu/dma-helpers.c
+++ b/softmmu/dma-helpers.c
@@ -164,8 +164,9 @@ static void dma_blk_cb(void *opaque, int ret)
 }
 }
 }
-if (!mem)
+if (!mem) {
 break;
+}
 qemu_iovec_add(>iov, mem, cur_len);
 dbs->sg_cur_byte += cur_len;
 if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) {
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 550cffe8f6..107ce0a4f8 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -664,8 +664,9 @@ void flatview_for_each_range(FlatView *fv, flatview_cb cb , 
void *opaque)
 assert(cb);

 FOR_EACH_FLAT_RANGE(fr, fv) {
-if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque))
+if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque)) {
 break;
+}
 }
 }

diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index a9adedb9f8..44ffb60b5d 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -797,8 +797,9 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr 
len,
 tlb_flush(cpu);
 }

-if (watchpoint)
+if (watchpoint) {
 *watchpoint = wp;
+}
 return 0;
 }

@@ -1210,8 +1211,9 @@ void flatview_add_to_dispatch(FlatView *fv, 
MemoryRegionSection *section)

 void qemu_flush_coalesced_mmio_buffer(void)
 {
-if (kvm_enabled())
+if (kvm_enabled()) {
 kvm_flush_coalesced_mmio_buffer();
+}
 }

 void qemu_mutex_lock_ramlist(void)
@@ -2495,8 +2497,9 @@ static int subpage_register(subpage_t *mmio, uint32_t 
start, uint32_t end,
 {
 int idx, eidx;

-if (start >= TARGET_PAGE_SIZE || end >= TARGET_PAGE_SIZE)
+if (start >= TARGET_PAGE_SIZE || end >= TARGET_PAGE_SIZE) {
 return -1;
+}
 idx = SUBPAGE_IDX(start);
 eidx = SUBPAGE_IDX(end);
 #if defined(DEBUG_SUBPAGE)
@@ -3408,11 +3411,13 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong 
addr,
 phys_addr = cpu_get_phys_page_attrs_debug(cpu, page, );
 asidx = cpu_asidx_from_attrs(cpu, attrs);
 /* if no physical page mapped, return an error */
-if (phys_addr == -1)
+if (phys_addr == -1) {
 return -1;
+}
 l = (page + TARGET_PAGE_SIZE) - addr;
-if (l > len)
+if (l > len) {
 l = len;
+}
 phys_addr += (addr & ~TARGET_PAGE_MASK);
 if (is_write) {
 res = address_space_write_rom(cpu->cpu_ases[asidx].as, phys_addr,
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index bcfb90a08f..e283d9c9c0 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -44,8 +44,7 @@
  * Aliases were a bad idea from the start.  Let's keep them
  * from spreading further.
  */
-typedef struct QDevAlias
-{
+typedef struct QDevAlias {
 const char *typename;
 const char *alias;
 uint32_t arch_mask;
@@ -180,10 +179,12 @@ static int set_property(void *opaque, const char *name, 
const char *value,
 {
 Object *obj = opaque;

-if (strcmp(name, "driver") == 0)
+if (strcmp(name, "driver") == 0) {
 return 0;
-if (strcmp(name, "bus") == 0)
+}
+if (strcmp(name, "bus") == 0) {
 return 0;
+}

 if (!object_property_parse(obj, name, value, errp)) {
 return -1;
@@ -694,8 +695,9 @@ static void qbus_print(Monitor *mon, BusState *bus, int 
indent);
 static void qdev_print_props(Monitor *mon, DeviceState *dev, 

[PATCH v2 2/3] softmmu: Don't use '#' flag of printf format

2020-11-02 Thread chaihaoyu
Hi, recently I found some code style problems while using checkpatch.pl 
tool,please review.

Date: Tue, 3 Nov 2020 11:01:40 +0800
Subject: [PATCH] Don't use '#' flag of printf format
signed-off-by: Haoyu Chai
---
 softmmu/device_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c
index b335dae707..c70215ba6a 100644
--- a/softmmu/device_tree.c
+++ b/softmmu/device_tree.c
@@ -367,7 +367,7 @@ int qemu_fdt_setprop_cell(void *fdt, const char *node_path,

 r = fdt_setprop_cell(fdt, findnode_nofail(fdt, node_path), property, val);
 if (r < 0) {
-error_report("%s: Couldn't set %s/%s = %#08x: %s", __func__,
+error_report("%s: Couldn't set %s/%s = 0x%08x: %s", __func__,
  node_path, property, val, fdt_strerror(r));
 exit(1);
 }
-- 
2.29.1.59.gf9b6481aed




[PATCH v2 1/3] softmmu: Do not use C99 // comments

2020-11-02 Thread chaihaoyu
Hi, recently I found some code style problems while using checkpatch.pl 
tool,please review.

Date: Tue, 3 Nov 2020 11:01:40 +0800
signed-off-by: Haoyu Chai
---
 softmmu/memory.c | 2 +-
 softmmu/memory_mapping.c | 2 +-
 softmmu/physmem.c| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/softmmu/memory.c b/softmmu/memory.c
index 107ce0a4f8..5fb591b001 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -36,7 +36,7 @@
 #include "hw/boards.h"
 #include "migration/vmstate.h"

-//#define DEBUG_UNASSIGNED
+/* #define DEBUG_UNASSIGNED */

 static unsigned memory_region_transaction_depth;
 static bool memory_region_update_pending;
diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
index 18d0b8067c..f64053499e 100644
--- a/softmmu/memory_mapping.c
+++ b/softmmu/memory_mapping.c
@@ -19,7 +19,7 @@
 #include "exec/memory.h"
 #include "exec/address-spaces.h"

-//#define DEBUG_GUEST_PHYS_REGION_ADD
+/* #define DEBUG_GUEST_PHYS_REGION_ADD */

 static void memory_mapping_list_add_mapping_sorted(MemoryMappingList *list,
MemoryMapping *mapping)
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 44ffb60b5d..78c1b6580a 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -75,7 +75,7 @@
 #include 
 #endif

-//#define DEBUG_SUBPAGE
+/* #define DEBUG_SUBPAGE */

 /* ram_list is read under rcu_read_lock()/rcu_read_unlock().  Writes
  * are protected by the ramlist lock.
-- 



[PATCH 1/1] plugin: foo * bar should be foo *bar

2020-10-29 Thread chaihaoyu
Date: Thu, 29 Oct 2020 15:53:44 +0800
signed-off-by: Haoyu Chai
Reported-by: Euler Robot 

---
 plugins/api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/api.c b/plugins/api.c
index bbdc5a4eb4..9661824b89 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -309,7 +309,7 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct 
qemu_plugin_hwaddr *haddr
  */

 #ifndef CONFIG_USER_ONLY
-static MachineState * get_ms(void)
+static MachineState *get_ms(void)
 {
 return MACHINE(qdev_get_machine());
 }
-- 



[PATCH] spaces are required in some places

2020-10-29 Thread chaihaoyu
Date: Thu, 29 Oct 2020 22:01:33 +0800
signed-off-by: Haoyu Chai
Reported-by: Euler Robot 

While reading softmmu related code, I found some style problems. Some spaces 
are required in softmmu/memory.c
---
 softmmu/memory.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/softmmu/memory.c b/softmmu/memory.c
index ee4a6bc168..550cffe8f6 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -158,7 +158,7 @@ enum ListenerDirection { Forward, Reverse };
 MemoryRegionSection mrs = section_from_flat_range(fr,   \
 address_space_to_flatview(as)); \
 MEMORY_LISTENER_CALL(as, callback, dir, , ##_args); \
-} while(0)
+} while (0)

 struct CoalescedMemoryRange {
 AddrRange addr;
@@ -329,7 +329,7 @@ static void flatview_simplify(FlatView *view)
 while (i < view->nr) {
 j = i + 1;
 while (j < view->nr
-   && can_merge(>ranges[j-1], >ranges[j])) {
+   && can_merge(>ranges[j - 1], >ranges[j])) {
 int128_addto(>ranges[i].addr.size, 
view->ranges[j].addr.size);
 ++j;
 }
@@ -834,8 +834,8 @@ static void address_space_update_ioeventfds(AddressSpace 
*as)
 ioeventfds = g_realloc(ioeventfds,
 ioeventfd_max * sizeof(*ioeventfds));
 }
-ioeventfds[ioeventfd_nb-1] = fr->mr->ioeventfds[i];
-ioeventfds[ioeventfd_nb-1].addr = tmp;
+ioeventfds[ioeventfd_nb - 1] = fr->mr->ioeventfds[i];
+ioeventfds[ioeventfd_nb - 1].addr = tmp;
 }
 }
 }
@@ -2343,8 +2343,8 @@ void memory_region_add_eventfd(MemoryRegion *mr,
 ++mr->ioeventfd_nb;
 mr->ioeventfds = g_realloc(mr->ioeventfds,
   sizeof(*mr->ioeventfds) * mr->ioeventfd_nb);
-memmove(>ioeventfds[i+1], >ioeventfds[i],
-sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb-1 - i));
+memmove(>ioeventfds[i + 1], >ioeventfds[i],
+sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - 1 - i));
 mr->ioeventfds[i] = mrfd;
 ioeventfd_update_pending |= mr->enabled;
 memory_region_transaction_commit();
@@ -2376,11 +2376,11 @@ void memory_region_del_eventfd(MemoryRegion *mr,
 }
 }
 assert(i != mr->ioeventfd_nb);
-memmove(>ioeventfds[i], >ioeventfds[i+1],
-sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i+1)));
+memmove(>ioeventfds[i], >ioeventfds[i + 1],
+sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i + 1)));
 --mr->ioeventfd_nb;
 mr->ioeventfds = g_realloc(mr->ioeventfds,
-  sizeof(*mr->ioeventfds)*mr->ioeventfd_nb + 
1);
+  sizeof(*mr->ioeventfds) * mr->ioeventfd_nb + 
1);
 ioeventfd_update_pending |= mr->enabled;
 memory_region_transaction_commit();
 }
--