qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] softmmu: some space-style problems while coding
@ 2021-01-15  3:52 chaihaoyu
  2021-01-15  3:55 ` [PATCH v2 1/5] softmmu: fix problems about spaces chaihaoyu
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: chaihaoyu @ 2021-01-15  3:52 UTC (permalink / raw)
  To: qemu-devel, pbonzini, Peter Xu, Paolo Bonzini; +Cc: alex.chen, hunongda

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/5] softmmu: fix problems about spaces
  2021-01-15  3:52 [PATCH v2 0/5] softmmu: some space-style problems while coding chaihaoyu
@ 2021-01-15  3:55 ` chaihaoyu
  2021-01-15  3:56 ` [PATCH v2 2/5] softmmu: braces {} are needed for if statement chaihaoyu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: chaihaoyu @ 2021-01-15  3:55 UTC (permalink / raw)
  To: qemu-devel, pbonzini, Peter Xu, Paolo Bonzini; +Cc: alex.chen, hunongda

This patch fixes error messages found by checkpatch.pl:
fix problems about spaces:

Signed-off-by: Haoyu Chai <chaihaoyu1@huawei.com>

---
 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(&list[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(&view->ranges[j-1], &view->ranges[j])) {
+               && can_merge(&view->ranges[j - 1], &view->ranges[j])) {
             int128_addto(&view->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(&mr->ioeventfds[i+1], &mr->ioeventfds[i],
-            sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb-1 - i));
+    memmove(&mr->ioeventfds[i + 1], &mr->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(&mr->ioeventfds[i], &mr->ioeventfds[i+1],
-            sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i+1)));
+    memmove(&mr->ioeventfds[i], &mr->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, &len) != 1) {
+        if (sscanf(path + pos, "%127[^/]%n", elem, &len) != 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, &len) != 1) {
+        if (sscanf(path + pos, "%127[^/]%n", elem, &len) != 1) {
             g_assert_not_reached();
             elem[0] = len = 0;
         }
-- 
2.29.1.59.gf9b6481aed


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/5] softmmu: braces {} are needed for if statement
  2021-01-15  3:52 [PATCH v2 0/5] softmmu: some space-style problems while coding chaihaoyu
  2021-01-15  3:55 ` [PATCH v2 1/5] softmmu: fix problems about spaces chaihaoyu
@ 2021-01-15  3:56 ` chaihaoyu
  2021-01-15  3:57 ` [PATCH v2 3/5] softmmu: don't use '#' flag of printf format ('%#') in format strings chaihaoyu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: chaihaoyu @ 2021-01-15  3:56 UTC (permalink / raw)
  To: qemu-devel, pbonzini, Peter Xu, Paolo Bonzini; +Cc: alex.chen, hunongda

This patch fixes error messages found by checkpatch.pl:
braces {} are needed for if statement

Signed-off-by: Haoyu Chai <chaihaoyu1@huawei.com>

---
 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(&dbs->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, &attrs);
         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())
+    if (sysbus_get_default()) {
         qbus_print(mon, sysbus_get_default(), 0);
+    }
 }

 void hmp_info_qdm(Monitor *mon, const QDict *qdict)
-- 
2.29.1.59.gf9b6481aed



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/5] softmmu: don't use '#' flag of printf format ('%#') in format strings
  2021-01-15  3:52 [PATCH v2 0/5] softmmu: some space-style problems while coding chaihaoyu
  2021-01-15  3:55 ` [PATCH v2 1/5] softmmu: fix problems about spaces chaihaoyu
  2021-01-15  3:56 ` [PATCH v2 2/5] softmmu: braces {} are needed for if statement chaihaoyu
@ 2021-01-15  3:57 ` chaihaoyu
  2021-01-15  3:57 ` [PATCH v2 4/5] softmmu: "foo* bar" should be "foo *bar" chaihaoyu
  2021-01-15  3:58 ` [PATCH v2 5/5] softmmu: code indent should never use tabs chaihaoyu
  4 siblings, 0 replies; 6+ messages in thread
From: chaihaoyu @ 2021-01-15  3:57 UTC (permalink / raw)
  To: qemu-devel, pbonzini, Peter Xu, Paolo Bonzini; +Cc: alex.chen, hunongda

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

Signed-off-by: Haoyu Chai <chaihaoyu1@huawei.com>

---
 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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/5] softmmu: "foo* bar" should be "foo *bar"
  2021-01-15  3:52 [PATCH v2 0/5] softmmu: some space-style problems while coding chaihaoyu
                   ` (2 preceding siblings ...)
  2021-01-15  3:57 ` [PATCH v2 3/5] softmmu: don't use '#' flag of printf format ('%#') in format strings chaihaoyu
@ 2021-01-15  3:57 ` chaihaoyu
  2021-01-15  3:58 ` [PATCH v2 5/5] softmmu: code indent should never use tabs chaihaoyu
  4 siblings, 0 replies; 6+ messages in thread
From: chaihaoyu @ 2021-01-15  3:57 UTC (permalink / raw)
  To: qemu-devel, pbonzini, Peter Xu, Paolo Bonzini; +Cc: alex.chen, hunongda

This patch fixes error messages found by checkpatch.pl:
"foo* bar" should be "foo *bar"

Signed-off-by: Haoyu Chai <chaihaoyu1@huawei.com>

---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 5/5] softmmu: code indent should never use tabs
  2021-01-15  3:52 [PATCH v2 0/5] softmmu: some space-style problems while coding chaihaoyu
                   ` (3 preceding siblings ...)
  2021-01-15  3:57 ` [PATCH v2 4/5] softmmu: "foo* bar" should be "foo *bar" chaihaoyu
@ 2021-01-15  3:58 ` chaihaoyu
  4 siblings, 0 replies; 6+ messages in thread
From: chaihaoyu @ 2021-01-15  3:58 UTC (permalink / raw)
  To: qemu-devel, pbonzini, Peter Xu, Paolo Bonzini; +Cc: alex.chen, hunongda

This patch fixes error messages found by checkpatch.pl:
code indent should never use tabs

Signed-off-by: Haoyu Chai <chaihaoyu1@huawei.com>

---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-15  4:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15  3:52 [PATCH v2 0/5] softmmu: some space-style problems while coding chaihaoyu
2021-01-15  3:55 ` [PATCH v2 1/5] softmmu: fix problems about spaces chaihaoyu
2021-01-15  3:56 ` [PATCH v2 2/5] softmmu: braces {} are needed for if statement chaihaoyu
2021-01-15  3:57 ` [PATCH v2 3/5] softmmu: don't use '#' flag of printf format ('%#') in format strings chaihaoyu
2021-01-15  3:57 ` [PATCH v2 4/5] softmmu: "foo* bar" should be "foo *bar" chaihaoyu
2021-01-15  3:58 ` [PATCH v2 5/5] softmmu: code indent should never use tabs chaihaoyu

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).