softmmu: some space-style problems while coding
v2 cover softmmu: some space-style problems while coding
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(-)
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH v2 1/5 softmmu: fix problems about spaces
This patch fixes error messages found by checkpatch.pl:
fix problems about spaces:
--- softmmu/bootdevice.c | 4 ++-- softmmu/memory.c | 16 ++++++++-------- softmmu/qdev-monitor.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-)
softmmu/bootdevice.c +2 -2
@@ -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 ;
softmmu/memory.c +8 -8
@@ -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 (); }
softmmu/qdev-monitor.c +2 -2
@@ -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 ; }
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH v2 2/5 softmmu: braces {} are needed for if statement
In reply to chaihaoyuThis patch fixes error messages found by checkpatch.pl:
braces {} are needed for if statement
--- 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(-)
softmmu/cpus.c +4 -2
@@ -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 );
softmmu/dma-helpers.c +2 -1
@@ -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) {
softmmu/memory.c +2 -1
@@ -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 ; + } } }
softmmu/physmem.c +10 -5
@@ -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,
softmmu/qdev-monitor.c +8 -4
@@ -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)
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH v2 3/5 softmmu: don't use '#' flag of printf format ('%#') in format strings
In reply to chaihaoyuThis patch fixes error messages found by checkpatch.pl:
don't use '#' flag of printf format ('%#') in format strings
--- softmmu/device_tree.c | 2 +- softmmu/runstate.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
softmmu/device_tree.c +1 -1
@@ -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 ); }
softmmu/runstate.c +2 -2
@@ -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,
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH v2 4/5 softmmu: "foo* bar" should be "foo *bar"
In reply to chaihaoyuThis patch fixes error messages found by checkpatch.pl:
"foo* bar" should be "foo *bar"
--- softmmu/globals.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
softmmu/globals.c +1 -1
@@ -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;
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH v2 5/5 softmmu: code indent should never use tabs
In reply to chaihaoyuThis patch fixes error messages found by checkpatch.pl:
code indent should never use tabs
--- softmmu/physmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
softmmu/physmem.c +1 -1
@@ -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;
Signature · 1 line
2.29.1.59.gf9b6481aed