cleanup: Tweak and re-run return_directly.cocci
Subsystems (5)
v2 cover cleanup: Tweak and re-run return_directly.cocci
Markus Armbruster (2):
cleanup: Tweak and re-run return_directly.cocci block/vmdk: Simplify vmdk_co_create() to return directly
scripts/coccinelle/return_directly.cocci | 5 +-- include/hw/pci/pci.h | 7 +-- target/avr/cpu.h | 4 +- block/vmdk.c | 28 +++++------- hw/9pfs/9p-synth.c | 14 ++---- hw/char/sifive_uart.c | 4 +- hw/ppc/ppc4xx_sdram.c | 5 +-- hw/rdma/vmw/pvrdma_cmd.c | 57 +++++++++--------------- hw/virtio/vhost-user.c | 6 +-- migration/dirtyrate.c | 10 +---- migration/tls.c | 6 +-- replay/replay-time.c | 5 +-- semihosting/console.c | 4 +- softmmu/memory.c | 11 +---- softmmu/physmem.c | 9 +--- target/loongarch/cpu.c | 4 +- target/mips/tcg/dsp_helper.c | 15 ++----- target/riscv/debug.c | 6 +-- target/riscv/vector_helper.c | 28 +++--------- tests/bench/benchmark-crypto-akcipher.c | 6 +-- tests/qtest/erst-test.c | 5 +-- tests/qtest/hexloader-test.c | 6 +-- tests/qtest/pvpanic-pci-test.c | 6 +-- tests/qtest/pvpanic-test.c | 6 +-- tests/qtest/test-filter-mirror.c | 6 +-- tests/qtest/virtio-ccw-test.c | 6 +-- tests/tcg/multiarch/sha512.c | 9 +--- tools/virtiofsd/fuse_lowlevel.c | 24 +++------- 28 files changed, 81 insertions(+), 221 deletions(-)
Signature · 1 line
2.37.3
PATCH v2 1/2 cleanup: Tweak and re-run return_directly.cocci
Tweak the semantic patch to drop redundant parenthesis around the return expression.
Coccinelle drops a comment in hw/rdma/vmw/pvrdma_cmd.c; restored manually.
Coccinelle messes up vmdk_co_create(), not sure why. Change dropped, will be done manually in the next commit.
Line breaks in target/avr/cpu.h and hw/rdma/vmw/pvrdma_cmd.c tidied up manually.
Whitespace in tools/virtiofsd/fuse_lowlevel.c tidied up manually.
checkpatch.pl complains "return of an errno should typically be -ve" two times for hw/9pfs/9p-synth.c. Preexisting, the patch merely makes it visible to checkpatch.pl.
--- scripts/coccinelle/return_directly.cocci | 5 +-- include/hw/pci/pci.h | 7 +-- target/avr/cpu.h | 4 +- hw/9pfs/9p-synth.c | 14 ++---- hw/char/sifive_uart.c | 4 +- hw/ppc/ppc4xx_sdram.c | 5 +-- hw/rdma/vmw/pvrdma_cmd.c | 57 +++++++++--------------- hw/virtio/vhost-user.c | 6 +-- migration/dirtyrate.c | 10 +---- migration/tls.c | 6 +-- replay/replay-time.c | 5 +-- semihosting/console.c | 4 +- softmmu/memory.c | 11 +---- softmmu/physmem.c | 9 +--- target/loongarch/cpu.c | 4 +- target/mips/tcg/dsp_helper.c | 15 ++----- target/riscv/debug.c | 6 +-- target/riscv/vector_helper.c | 28 +++--------- tests/bench/benchmark-crypto-akcipher.c | 6 +-- tests/qtest/erst-test.c | 5 +-- tests/qtest/hexloader-test.c | 6 +-- tests/qtest/pvpanic-pci-test.c | 6 +-- tests/qtest/pvpanic-test.c | 6 +-- tests/qtest/test-filter-mirror.c | 6 +-- tests/qtest/virtio-ccw-test.c | 6 +-- tests/tcg/multiarch/sha512.c | 9 +--- tools/virtiofsd/fuse_lowlevel.c | 24 +++------- 27 files changed, 70 insertions(+), 204 deletions(-)
scripts/coccinelle/return_directly.cocci +2 -3
@@ -11,9 +11,8 @@ identifier F; - T VAR; ... when != VAR -- VAR = -+ return - E; +- VAR = (E); - return VAR; ++ return E; ... when != VAR }
include/hw/pci/pci.h +2 -5
@@ -921,11 +921,8 @@ PCI_DMA_DEFINE_LDST(q_be, q_be, 64);static inline void *pci_dma_map (PCIDevice *dev,dma_addr_t addr,dma_addr_t *plen,DMADirection dir) { -void *buf; - - buf =dma_memory_map (pci_get_address_space (dev), addr, plen, dir, -MEMTXATTRS_UNSPECIFIED ); -return buf; +return dma_memory_map (pci_get_address_space (dev), addr, plen, dir, +MEMTXATTRS_UNSPECIFIED ); } static inline void pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len,
target/avr/cpu.h +1 -3
@@ -215,8 +215,7 @@ static inline int cpu_interrupts_enabled(CPUAVRState *env)static inline uint8_t cpu_get_sreg (CPUAVRState *env) { -uint8_t sreg; - sreg = (env->sregC) <<0 +return (env->sregC) <<0 | (env->sregZ) <<1 | (env->sregN) <<2 | (env->sregV) <<3
@@ -224,7 +223,6 @@ static inline uint8_t cpu_get_sreg(CPUAVRState *env) | (env->sregH) << 5 | (env->sregT) <<6 | (env->sregI) <<7 ; -return sreg; }static inline void cpu_set_sreg (CPUAVRState *env,uint8_t sreg)
hw/9pfs/9p-synth.c +4 -10
@@ -72,7 +72,6 @@ static V9fsSynthNode *v9fs_add_dir_node(V9fsSynthNode *parent, int mode,int qemu_v9fs_synth_mkdir (V9fsSynthNode *parent,int mode,const char *name,V9fsSynthNode **result) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {
@@ -87,8 +86,7 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add the name */
@@ -98,15 +96,13 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,v9fs_add_dir_node (node, node->attr->mode,"." , node->attr, node->attr->inode); *result = node; - ret =0 ; -return ret; +return 0 ; }int qemu_v9fs_synth_add_file (V9fsSynthNode *parent,int mode,const char *name,v9fs_synth_read read,v9fs_synth_write write,void *arg) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {
@@ -122,8 +118,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add file type and remove write bits */
@@ -138,8 +133,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode, node->private = arg;pstrcpy (node->name,sizeof (node->name), name);QLIST_INSERT_HEAD_RCU (&parent->child, node, sibling); - ret =0 ; -return ret; +return 0 ; }static void synth_fill_statbuf (V9fsSynthNode *node,struct stat *stbuf)
hw/char/sifive_uart.c +1 -3
@@ -274,7 +274,6 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, {DeviceState *dev;SysBusDevice *s; -SiFiveUARTState *r; dev =qdev_new ("riscv.sifive.uart" ); s =SYS_BUS_DEVICE (dev);
@@ -284,6 +283,5 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, sysbus_mmio_get_region(s, 0));sysbus_connect_irq (s,0 , irq); - r =SIFIVE_UART (dev); -return r; +return SIFIVE_UART (dev); }
hw/ppc/ppc4xx_sdram.c +1 -4
@@ -520,13 +520,10 @@ static inline hwaddr sdram_ddr2_base(uint32_t bcr)static hwaddr sdram_ddr2_size (uint32_t bcr) { -hwaddr size;int sh; sh =1024 - ((bcr >>6 ) &0x3ff ); - size =8 * MiB * sh; - -return size; +return 8 * MiB * sh; }static uint32_t sdram_ddr2_dcr_read (void *opaque,int dcrn)
hw/rdma/vmw/pvrdma_cmd.c +20 -37
114 lines not on this page · raw message
hw/virtio/vhost-user.c +1 -5
@@ -2532,11 +2532,7 @@ vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id)static bool vhost_user_mem_section_filter (struct vhost_dev *dev,MemoryRegionSection *section) { -bool result; - - result =memory_region_get_fd (section->mr) >=0 ; - -return result; +return memory_region_get_fd (section->mr) >=0 ; } static int vhost_user_get_inflight_fd(struct vhost_dev *dev,
migration/dirtyrate.c +2 -8
@@ -111,7 +111,6 @@ static void global_dirty_log_sync(unsigned int flag, bool one_shot)static DirtyPageRecord *vcpu_dirty_stat_alloc (VcpuStat *stat) {CPUState *cpu; -DirtyPageRecord *records;int nvcpu =0 ;CPU_FOREACH (cpu) {
@@ -121,9 +120,7 @@ static DirtyPageRecord *vcpu_dirty_stat_alloc(VcpuStat *stat) stat->nvcpu = nvcpu; stat->rates =g_new0 (DirtyRateVcpu, nvcpu); - records =g_new0 (DirtyPageRecord, nvcpu); - -return records; +return g_new0 (DirtyPageRecord, nvcpu); } static void vcpu_dirty_stat_collect(VcpuStat *stat,
@@ -473,7 +470,6 @@ find_block_matched(RAMBlock *block, int count, struct RamblockDirtyInfo *infos) {int i; -struct RamblockDirtyInfo *matched;for (i =0 ; i < count; i++) {if (!strcmp (infos[i].idstr,qemu_ram_get_idstr (block))) {
@@ -492,9 +488,7 @@ find_block_matched(RAMBlock *block, int count,return NULL ; } - matched = &infos[i]; - -return matched; +return &infos[i]; } static bool compare_page_hash_info(struct RamblockDirtyInfo *info,
migration/tls.c +1 -5
@@ -126,7 +126,6 @@ QIOChannelTLS *migration_tls_client_create(MigrationState *s, Error **errp) {QCryptoTLSCreds *creds; -QIOChannelTLS *tioc; creds =migration_tls_get_creds ( s,QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT , errp);
@@ -138,10 +137,7 @@ QIOChannelTLS *migration_tls_client_create(MigrationState *s, hostname = s->parameters.tls_hostname; } - tioc =qio_channel_tls_new_client ( - ioc, creds, hostname, errp); - -return tioc; +return qio_channel_tls_new_client (ioc, creds, hostname, errp); } void migration_tls_channel_connect(MigrationState *s,
replay/replay-time.c +1 -4
@@ -48,7 +48,6 @@ void replay_read_next_clock(ReplayClockKind kind)/*! Reads next clock event from the input. */ int64_t replay_read_clock (ReplayClockKind kind,int64_t raw_icount) { -int64_t ret;g_assert (replay_file &&replay_mutex_locked ());replay_advance_current_icount (raw_icount);
@@ -56,7 +55,5 @@ int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount)if (replay_next_event_is (EVENT_CLOCK + kind)) {replay_read_next_clock (kind); } - ret = replay_state.cached_clock[kind]; - -return ret; +return replay_state.cached_clock[kind]; }
semihosting/console.c +1 -3
@@ -43,10 +43,8 @@ static SemihostingConsole console;static int console_can_read (void *opaque) {SemihostingConsole *c = opaque; -int ret;g_assert (qemu_mutex_iothread_locked ()); - ret = (int )fifo8_num_free (&c->fifo); -return ret; +return (int )fifo8_num_free (&c->fifo); }static void console_wake_up (gpointer data,gpointer user_data)
softmmu/memory.c +2 -9
@@ -2372,20 +2372,15 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,int memory_region_get_fd (MemoryRegion *mr) { -int fd; -RCU_READ_LOCK_GUARD ();while (mr->alias) { mr = mr->alias; } - fd = mr->ram_block->fd; - -return fd; +return mr->ram_block->fd; }void *memory_region_get_ram_ptr (MemoryRegion *mr) { -void *ptr;uint64_t offset =0 ;RCU_READ_LOCK_GUARD ();
@@ -2394,9 +2389,7 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr) mr = mr->alias; }assert (mr->ram_block); - ptr =qemu_map_ram_ptr (mr->ram_block, offset); - -return ptr; +return qemu_map_ram_ptr (mr->ram_block, offset); }MemoryRegion *memory_region_from_host (void *ptr,ram_addr_t *offset)
softmmu/physmem.c +2 -7
@@ -3236,7 +3236,6 @@ void *address_space_map(AddressSpace *as,hwaddr len = *plen;hwaddr l, xlat;MemoryRegion *mr; -void *ptr;FlatView *fv;if (len ==0 ) {
@@ -3275,9 +3274,7 @@ void *address_space_map(AddressSpace *as, *plen =flatview_extend_translation (fv, addr, len, mr, xlat, l, is_write, attrs);fuzz_dma_read_cb (addr, *plen, mr); - ptr =qemu_ram_ptr_length (mr->ram_block, xlat, plen, true); - -return ptr; +return qemu_ram_ptr_length (mr->ram_block, xlat, plen, true); }/* Unmaps a memory region previously mapped by address_space_map().
@@ -3545,15 +3542,13 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) {MemoryRegion *mr;hwaddr l =1 ; -bool res;RCU_READ_LOCK_GUARD (); mr =address_space_translate (&address_space_memory, phys_addr, &phys_addr, &l, false,MEMTXATTRS_UNSPECIFIED ); - res = !(memory_region_is_ram (mr) ||memory_region_is_romd (mr)); -return res; +return !(memory_region_is_ram (mr) ||memory_region_is_romd (mr)); }int qemu_ram_foreach_block (RAMBlockIterFunc func,void *opaque)
target/loongarch/cpu.c +1 -3
@@ -128,13 +128,11 @@ static inline bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env) {uint32_t pending;uint32_t status; -bool r; pending =FIELD_EX64 (env->CSR_ESTAT,CSR_ESTAT ,IS ); status =FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,LIE ); - r = (pending & status) !=0 ; -return r; +return (pending & status) !=0 ; }static void loongarch_cpu_do_interrupt (CPUState *cs)
target/mips/tcg/dsp_helper.c +3 -12
@@ -3281,15 +3281,12 @@ target_ulong helper_dextr_l(target_ulong ac, target_ulong shift, CPUMIPSState *env) {uint64_t temp[3 ]; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env); - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); } target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,
@@ -3297,7 +3294,6 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift, {uint64_t temp[3 ];uint32_t temp128; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env);
@@ -3317,9 +3313,7 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,set_DSPControl_overflow_flag (1 ,23 , env); } - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); } target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift,
@@ -3327,7 +3321,6 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift, {uint64_t temp[3 ];uint32_t temp128; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env);
@@ -3354,9 +3347,7 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift, set_DSPControl_overflow_flag(1, 23, env); } - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); }#endif
target/riscv/debug.c +2 -4
@@ -243,15 +243,13 @@ static void do_trigger_action(CPURISCVState *env, target_ulong trigger_index)static uint32_t type2_breakpoint_size (CPURISCVState *env,target_ulong ctrl) { -uint32_t size, sizelo, sizehi =0 ; +uint32_t sizelo, sizehi =0 ;if (riscv_cpu_mxl (env) ==MXL_RV64 ) { sizehi =extract32 (ctrl,21 ,2 ); } sizelo =extract32 (ctrl,16 ,2 ); - size = (sizehi <<2 ) | sizelo; - -return size; +return (sizehi <<2 ) | sizelo; }static inline bool type2_breakpoint_enabled (target_ulong ctrl)
target/riscv/vector_helper.c +7 -21
@@ -2791,31 +2791,25 @@ static inline uint16_t vssrl16(CPURISCVState *env, int vxrm, uint16_t a, uint16_t b) {uint8_t round, shift = b &0xf ; -uint16_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline uint32_t vssrl32 (CPURISCVState *env,int vxrm,uint32_t a,uint32_t b) {uint8_t round, shift = b &0x1f ; -uint32_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline uint64_t vssrl64 (CPURISCVState *env,int vxrm,uint64_t a,uint64_t b) {uint8_t round, shift = b &0x3f ; -uint64_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; } RVVCALL(OPIVV2_RM, vssrl_vv_b, OP_UUU_B, H1, H1, H1, vssrl8)RVVCALL (OPIVV2_RM , vssrl_vv_h,OP_UUU_H ,H2 ,H2 ,H2 , vssrl16)
@@ -2839,41 +2833,33 @@ static inline int8_t vssra8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) {uint8_t round, shift = b &0x7 ; -int8_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int16_t vssra16 (CPURISCVState *env,int vxrm,int16_t a,int16_t b) {uint8_t round, shift = b &0xf ; -int16_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int32_t vssra32 (CPURISCVState *env,int vxrm,int32_t a,int32_t b) {uint8_t round, shift = b &0x1f ; -int32_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int64_t vssra64 (CPURISCVState *env,int vxrm,int64_t a,int64_t b) {uint8_t round, shift = b &0x3f ; -int64_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }RVVCALL (OPIVV2_RM , vssra_vv_b,OP_SSS_B ,H1 ,H1 ,H1 , vssra8)
tests/bench/benchmark-crypto-akcipher.c +2 -4
@@ -24,14 +24,12 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, QCryptoHashAlgorithm hash) {QCryptoAkCipherOptions opt; -QCryptoAkCipher *rsa; opt.alg =QCRYPTO_AKCIPHER_ALG_RSA ; opt.u.rsa.padding_alg = padding; opt.u.rsa.hash_alg = hash; - rsa =qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , - priv_key, keylen, &error_abort); -return rsa; +return qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , + priv_key, keylen, &error_abort); } static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
tests/qtest/erst-test.c +1 -4
@@ -154,10 +154,7 @@ static void test_acpi_erst_basic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/acpi-erst/basic" , test_acpi_erst_basic); - ret =g_test_run (); -return ret; +return g_test_run (); }
tests/qtest/hexloader-test.c +1 -5
@@ -34,12 +34,8 @@ static void hex_loader_test(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/tmp/hex_loader" , hex_loader_test); - ret =g_test_run (); - -return ret; +return g_test_run (); }
tests/qtest/pvpanic-pci-test.c +1 -5
@@ -86,13 +86,9 @@ static void test_panic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic-pci/panic" , test_panic);qtest_add_func ("/pvpanic-pci/panic-nopause" , test_panic_nopause); - ret =g_test_run (); - -return ret; +return g_test_run (); }
tests/qtest/pvpanic-test.c +1 -5
@@ -59,13 +59,9 @@ static void test_panic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic/panic" , test_panic);qtest_add_func ("/pvpanic/panic-nopause" , test_panic_nopause); - ret =g_test_run (); - -return ret; +return g_test_run (); }
tests/qtest/test-filter-mirror.c +1 -5
@@ -76,12 +76,8 @@ static void test_mirror(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/netfilter/mirror" , test_mirror); - ret =g_test_run (); - -return ret; +return g_test_run (); }
tests/qtest/virtio-ccw-test.c +1 -5
@@ -95,8 +95,6 @@ static void virtio_scsi_hotplug(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/virtio/balloon/nop" , virtio_balloon_nop);qtest_add_func ("/virtio/console/nop" , virtconsole_nop);
@@ -109,7 +107,5 @@ int main(int argc, char **argv)qtest_add_func ("/virtio/scsi/nop" , virtio_scsi_nop);qtest_add_func ("/virtio/scsi/hotplug" , virtio_scsi_hotplug); - ret =g_test_run (); - -return ret; +return g_test_run (); }
tests/tcg/multiarch/sha512.c +2 -7
@@ -855,8 +855,6 @@ plan_tests(unsigned int tests)static int exit_status_ (void ) { -int r; -/* If there's no plan, just return the number of failures */ if (no_plan || !have_plan) {return failures;
@@ -865,15 +863,12 @@ exit_status_(void)/* Ran too many tests? Return the number of tests that were run that shouldn't have been */ if (e_tests < test_count) { - r = test_count - e_tests; -return r; +return test_count - e_tests; }/* Return the number of tests that failed + the number of tests that weren't run */ - r = failures + e_tests - test_count; - -return r; +return failures + e_tests - test_count; }int
tools/virtiofsd/fuse_lowlevel.c +6 -18
@@ -216,7 +216,6 @@ static int send_reply(fuse_req_t req, int error, const void *arg,int fuse_reply_iov (fuse_req_t req,const struct iovec *iov,int count) { -int res; g_autofree struct iovec *padded_iov = NULL; padded_iov = g_try_new(struct iovec, count + 1);
@@ -227,9 +226,7 @@ int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)memcpy (padded_iov +1 , iov, count *sizeof (struct iovec )); count++; - res =send_reply_iov (req,0 , padded_iov, count); - -return res; +return send_reply_iov (req,0 , padded_iov, count); }
@@ -589,7 +586,6 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov, g_autofree struct fuse_ioctl_iovec *out_fiov = NULL;struct iovec iov[4 ];size_t count =1 ; -int res;memset (&arg,0 ,sizeof (arg)); arg.flags |=FUSE_IOCTL_RETRY ;
@@ -601,15 +597,13 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,/* Can't handle non-compat 64bit ioctls on 32bit */ if (sizeof (void *) ==4 && req->ioctl_64bit) { - res =fuse_reply_err (req,EINVAL ); -return res; +return fuse_reply_err (req,EINVAL ); }if (in_count) { in_fiov =fuse_ioctl_iovec_copy (in_iov, in_count);if (!in_fiov) { - res =fuse_reply_err (req,ENOMEM ); -return res; +return fuse_reply_err (req,ENOMEM ); } iov[count].iov_base = (void *)in_fiov;
@@ -619,8 +613,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,if (out_count) { out_fiov =fuse_ioctl_iovec_copy (out_iov, out_count);if (!out_fiov) { - res =fuse_reply_err (req,ENOMEM ); -return res; +return fuse_reply_err (req,ENOMEM ); } iov[count].iov_base = (void *)out_fiov;
@@ -628,9 +621,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov, count++; } - res =send_reply_iov (req,0 , iov, count); - -return res; +return send_reply_iov (req,0 , iov, count); }int fuse_reply_ioctl (fuse_req_t req,int result,const void *buf,size_t size)
@@ -659,7 +650,6 @@ int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov, { g_autofree struct iovec *padded_iov = NULL;struct fuse_ioctl_out arg; -int res; padded_iov = g_try_new(struct iovec, count + 2);if (padded_iov ==NULL ) {
@@ -673,9 +663,7 @@ int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov,memcpy (&padded_iov[2 ], iov, count *sizeof (struct iovec )); - res =send_reply_iov (req,0 , padded_iov, count +2 ); - -return res; +return send_reply_iov (req,0 , padded_iov, count +2 ); }int fuse_reply_poll (fuse_req_t req,unsigned revents)
Signature · 1 line
2.37.3
Quoted 193 lines · Markus Armbruster
Tweak the semantic patch to drop redundant parenthesis around the return expression.
Coccinelle drops a comment in
hw/rdma/vmw/pvrdma_cmd.c; restored manually.Coccinelle messes up
vmdk_co_create(), not sure why. Change dropped, will be done manually in the next commit.Line breaks in
target/avr/cpu.handhw/rdma/vmw/pvrdma_cmd.ctidied up manually.Whitespace in
tools/virtiofsd/fuse_lowlevel.ctidied up manually.checkpatch.pl complains "return of an errno should typically be -ve" two times for
hw/9pfs/9p-synth.c. Preexisting, the patch merely makes it visible to checkpatch.pl.Signed-off-by Markus Armbruster <[email protected]>---
scripts/coccinelle/return_directly.cocci | 5 +-- include/hw/pci/pci.h | 7 +-- target/avr/cpu.h | 4 +- hw/9pfs/9p-synth.c | 14 ++---- hw/char/sifive_uart.c | 4 +- hw/ppc/ppc4xx_sdram.c | 5 +-- hw/rdma/vmw/pvrdma_cmd.c | 57 +++++++++--------------- hw/virtio/vhost-user.c | 6 +-- migration/dirtyrate.c | 10 +---- migration/tls.c | 6 +-- replay/replay-time.c | 5 +-- semihosting/console.c | 4 +- softmmu/memory.c | 11 +---- softmmu/physmem.c | 9 +--- target/loongarch/cpu.c | 4 +- target/mips/tcg/dsp_helper.c | 15 ++----- target/riscv/debug.c | 6 +-- target/riscv/vector_helper.c | 28 +++--------- tests/bench/benchmark-crypto-akcipher.c | 6 +-- tests/qtest/erst-test.c | 5 +-- tests/qtest/hexloader-test.c | 6 +-- tests/qtest/pvpanic-pci-test.c | 6 +-- tests/qtest/pvpanic-test.c | 6 +-- tests/qtest/test-filter-mirror.c | 6 +-- tests/qtest/virtio-ccw-test.c | 6 +-- tests/tcg/multiarch/sha512.c | 9 +--- tools/virtiofsd/fuse_lowlevel.c | 24 +++------- 27 files changed, 70 insertions(+), 204 deletions(-)scripts/coccinelle/return_directly.cocci +2
-5@@ -11,9 +11,8 @@ identifier F; - T VAR; ... when != VAR -- VAR = -+ return - E; +- VAR = (E); - return VAR; ++ return E; ... when != VAR }include/hw/pci/pci.h +2
-5@@ -921,11 +921,8 @@ PCI_DMA_DEFINE_LDST(q_be, q_be, 64);static inline void *pci_dma_map (PCIDevice *dev,dma_addr_t addr,dma_addr_t *plen,DMADirection dir) { -void *buf; - - buf =dma_memory_map (pci_get_address_space (dev), addr, plen, dir, -MEMTXATTRS_UNSPECIFIED ); -return buf; +return dma_memory_map (pci_get_address_space (dev), addr, plen, dir, +MEMTXATTRS_UNSPECIFIED ); } static inline void pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len,target/avr/cpu.h +1
-3@@ -215,8 +215,7 @@ static inline int cpu_interrupts_enabled(CPUAVRState *env)static inline uint8_t cpu_get_sreg (CPUAVRState *env) { -uint8_t sreg; - sreg = (env->sregC) <<0 +return (env->sregC) <<0 | (env->sregZ) <<1 | (env->sregN) <<2 | (env->sregV) <<3 @@ -224,7 +223,6 @@ static inline uint8_t cpu_get_sreg(CPUAVRState *env) | (env->sregH) << 5 | (env->sregT) <<6 | (env->sregI) <<7 ; -return sreg; }static inline void cpu_set_sreg (CPUAVRState *env,uint8_t sreg)hw/9pfs/9p-synth.c +4
-10@@ -72,7 +72,6 @@ static V9fsSynthNode *v9fs_add_dir_node(V9fsSynthNode *parent, int mode,int qemu_v9fs_synth_mkdir (V9fsSynthNode *parent,int mode,const char *name,V9fsSynthNode **result) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {@@ -87,8 +86,7 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add the name */ @@ -98,15 +96,13 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,v9fs_add_dir_node (node, node->attr->mode,"." , node->attr, node->attr->inode); *result = node; - ret =0 ; -return ret; +return 0 ; }int qemu_v9fs_synth_add_file (V9fsSynthNode *parent,int mode,const char *name,v9fs_synth_read read,v9fs_synth_write write,void *arg) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {@@ -122,8 +118,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add file type and remove write bits */ @@ -138,8 +133,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode, node->private = arg;pstrcpy (node->name,sizeof (node->name), name);QLIST_INSERT_HEAD_RCU (&parent->child, node, sibling); - ret =0 ; -return ret; +return 0 ; }static void synth_fill_statbuf (V9fsSynthNode *node,struct stat *stbuf)hw/char/sifive_uart.c +1
-3@@ -274,7 +274,6 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, {DeviceState *dev;SysBusDevice *s; -SiFiveUARTState *r; dev =qdev_new ("riscv.sifive.uart" ); s =SYS_BUS_DEVICE (dev);@@ -284,6 +283,5 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, sysbus_mmio_get_region(s, 0));sysbus_connect_irq (s,0 , irq); - r =SIFIVE_UART (dev); -return r; +return SIFIVE_UART (dev); }hw/ppc/ppc4xx_sdram.c +0
-1@@ -520,13 +520,10 @@ static inline hwaddr sdram_ddr2_base(uint32_t bcr)static hwaddr sdram_ddr2_size (uint32_t bcr) { -hwaddr size;
hw/ppc/ppc4xx_sdram.c static inline hwaddr sdram_ddr2_base(uint32_t bcr) · line 529
Quoted 10 lines
hw/ppc/ppc4xx_sdram.c +1
-3int sh; sh =1024 - ((bcr >>6 ) &0x3ff ); - size =8 * MiB * sh; - -return size; +return 8 * MiB * sh; }static uint32_t sdram_ddr2_dcr_read (void *opaque,int dcrn)
There's also an sdram_ddr_size() that's similar and could be changed to
return sh == 7 ? -1 : (4 * MiB) << sh;
just to keep these two functions simliar but Coccinelle probably does not catch that. Also while you're at it the assigmment of sh could be moved to the declaration to save even more lines. As this then becomes more of a handwritten patch, maybe it should be a separate patch cleaning these two functions before the rest.
Otherwise for this part (or separate patch as above):
Regards,
BALATON Zoltan
Quoted 20 lines · BALATON Zoltan
Quoted 19 lines · Markus Armbruster
Tweak the semantic patch to drop redundant parenthesis around the return expression.
Coccinelle drops a comment in
hw/rdma/vmw/pvrdma_cmd.c; restored manually.Coccinelle messes up
vmdk_co_create(), not sure why. Change dropped, will be done manually in the next commit.Line breaks in
target/avr/cpu.handhw/rdma/vmw/pvrdma_cmd.ctidied up manually.Whitespace in
tools/virtiofsd/fuse_lowlevel.ctidied up manually.checkpatch.pl complains "return of an errno should typically be -ve" two times for
hw/9pfs/9p-synth.c. Preexisting, the patch merely makes it visible to checkpatch.pl.Signed-off-by Markus Armbruster <[email protected]>
[...]
Quoted 22 lines
Quoted 9 lines
hw/ppc/ppc4xx_sdram.c +0
-1@@ -520,13 +520,10 @@ static inline hwaddr sdram_ddr2_base(uint32_t bcr)static hwaddr sdram_ddr2_size (uint32_t bcr) { -hwaddr size;hw/ppc/ppc4xx_sdram.c static inline hwaddr sdram_ddr2_base(uint32_t bcr) · line 529
Quoted 10 lines
hw/ppc/ppc4xx_sdram.c +1
-3int sh; sh =1024 - ((bcr >>6 ) &0x3ff ); - size =8 * MiB * sh; - -return size; +return 8 * MiB * sh; }static uint32_t sdram_ddr2_dcr_read (void *opaque,int dcrn)There's also an
sdram_ddr_size()that's similar and could be changed to
Quoted 5 lines
return sh == 7 ? -1 : (4 * MiB) << sh;
just to keep these two functions simliar but Coccinelle probably does not catch that. Also while you're at it the assigmment of sh could be moved to the declaration to save even more lines. As this then becomes more of a handwritten patch, maybe it should be a separate patch cleaning these two functions before the rest.
I think it needs to be separate to keep me off Peter's naughty list ;)
Quoted 3 lines
Otherwise for this part (or separate patch as above):
Reviewed-by BALATON Zoltan <[email protected]>
Thanks!
Quoted 55 lines · Markus Armbruster
Tweak the semantic patch to drop redundant parenthesis around the return expression.
Coccinelle drops a comment in
hw/rdma/vmw/pvrdma_cmd.c; restored manually.Coccinelle messes up
vmdk_co_create(), not sure why. Change dropped, will be done manually in the next commit.Line breaks in
target/avr/cpu.handhw/rdma/vmw/pvrdma_cmd.ctidied up manually.Whitespace in
tools/virtiofsd/fuse_lowlevel.ctidied up manually.checkpatch.pl complains "return of an errno should typically be -ve" two times for
hw/9pfs/9p-synth.c. Preexisting, the patch merely makes it visible to checkpatch.pl.Signed-off-by Markus Armbruster <[email protected]>--- scripts/coccinelle/return_directly.cocci | 5 +-- include/hw/pci/pci.h | 7 +-- target/avr/cpu.h | 4 +- hw/9pfs/9p-synth.c | 14 ++---- hw/char/sifive_uart.c | 4 +- hw/ppc/ppc4xx_sdram.c | 5 +-- hw/rdma/vmw/pvrdma_cmd.c | 57 +++++++++--------------- hw/virtio/vhost-user.c | 6 +-- migration/dirtyrate.c | 10 +---- migration/tls.c | 6 +-- replay/replay-time.c | 5 +-- semihosting/console.c | 4 +- softmmu/memory.c | 11 +---- softmmu/physmem.c | 9 +--- target/loongarch/cpu.c | 4 +- target/mips/tcg/dsp_helper.c | 15 ++----- target/riscv/debug.c | 6 +-- target/riscv/vector_helper.c | 28 +++--------- tests/bench/benchmark-crypto-akcipher.c | 6 +-- tests/qtest/erst-test.c | 5 +-- tests/qtest/hexloader-test.c | 6 +-- tests/qtest/pvpanic-pci-test.c | 6 +-- tests/qtest/pvpanic-test.c | 6 +-- tests/qtest/test-filter-mirror.c | 6 +-- tests/qtest/virtio-ccw-test.c | 6 +-- tests/tcg/multiarch/sha512.c | 9 +--- tools/virtiofsd/fuse_lowlevel.c | 24 +++------- 27 files changed, 70 insertions(+), 204 deletions(-)scripts/coccinelle/return_directly.cocci +0
-0@@ -11,9 +11,8 @@ identifier F; - T VAR;
scripts/coccinelle/return_directly.cocci identifier F; · line 18
Quoted 10 lines
scripts/coccinelle/return_directly.cocci +2
-3... when != VAR -- VAR = -+ return - E; +- VAR = (E); - return VAR; ++ return E; ... when != VAR }
Quoted 12 lines · * Markus Armbruster ([email protected]) wrote:
Tweak the semantic patch to drop redundant parenthesis around the return expression.
Coccinelle drops a comment in
hw/rdma/vmw/pvrdma_cmd.c; restored manually.Coccinelle messes up
vmdk_co_create(), not sure why. Change dropped, will be done manually in the next commit.Line breaks in
target/avr/cpu.handhw/rdma/vmw/pvrdma_cmd.ctidied up manually.
Quoted 7 lines
Whitespace in
tools/virtiofsd/fuse_lowlevel.ctidied up manually.checkpatch.pl complains "return of an errno should typically be -ve" two times for
hw/9pfs/9p-synth.c. Preexisting, the patch merely makes it visible to checkpatch.pl.Signed-off-by Markus Armbruster <[email protected]>
For migration and virtiofs:
Quoted 945 lines
--- scripts/coccinelle/return_directly.cocci | 5 +-- include/hw/pci/pci.h | 7 +-- target/avr/cpu.h | 4 +- hw/9pfs/9p-synth.c | 14 ++---- hw/char/sifive_uart.c | 4 +- hw/ppc/ppc4xx_sdram.c | 5 +-- hw/rdma/vmw/pvrdma_cmd.c | 57 +++++++++--------------- hw/virtio/vhost-user.c | 6 +-- migration/dirtyrate.c | 10 +---- migration/tls.c | 6 +-- replay/replay-time.c | 5 +-- semihosting/console.c | 4 +- softmmu/memory.c | 11 +---- softmmu/physmem.c | 9 +--- target/loongarch/cpu.c | 4 +- target/mips/tcg/dsp_helper.c | 15 ++----- target/riscv/debug.c | 6 +-- target/riscv/vector_helper.c | 28 +++--------- tests/bench/benchmark-crypto-akcipher.c | 6 +-- tests/qtest/erst-test.c | 5 +-- tests/qtest/hexloader-test.c | 6 +-- tests/qtest/pvpanic-pci-test.c | 6 +-- tests/qtest/pvpanic-test.c | 6 +-- tests/qtest/test-filter-mirror.c | 6 +-- tests/qtest/virtio-ccw-test.c | 6 +-- tests/tcg/multiarch/sha512.c | 9 +--- tools/virtiofsd/fuse_lowlevel.c | 24 +++------- 27 files changed, 70 insertions(+), 204 deletions(-)scripts/coccinelle/return_directly.cocci +2
-3@@ -11,9 +11,8 @@ identifier F; - T VAR; ... when != VAR -- VAR = -+ return - E; +- VAR = (E); - return VAR; ++ return E; ... when != VAR }include/hw/pci/pci.h +2
-5@@ -921,11 +921,8 @@ PCI_DMA_DEFINE_LDST(q_be, q_be, 64);static inline void *pci_dma_map (PCIDevice *dev,dma_addr_t addr,dma_addr_t *plen,DMADirection dir) { -void *buf; - - buf =dma_memory_map (pci_get_address_space (dev), addr, plen, dir, -MEMTXATTRS_UNSPECIFIED ); -return buf; +return dma_memory_map (pci_get_address_space (dev), addr, plen, dir, +MEMTXATTRS_UNSPECIFIED ); } static inline void pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len,target/avr/cpu.h +1
-3@@ -215,8 +215,7 @@ static inline int cpu_interrupts_enabled(CPUAVRState *env)static inline uint8_t cpu_get_sreg (CPUAVRState *env) { -uint8_t sreg; - sreg = (env->sregC) <<0 +return (env->sregC) <<0 | (env->sregZ) <<1 | (env->sregN) <<2 | (env->sregV) <<3 @@ -224,7 +223,6 @@ static inline uint8_t cpu_get_sreg(CPUAVRState *env) | (env->sregH) << 5 | (env->sregT) <<6 | (env->sregI) <<7 ; -return sreg; }static inline void cpu_set_sreg (CPUAVRState *env,uint8_t sreg)hw/9pfs/9p-synth.c +4
-10@@ -72,7 +72,6 @@ static V9fsSynthNode *v9fs_add_dir_node(V9fsSynthNode *parent, int mode,int qemu_v9fs_synth_mkdir (V9fsSynthNode *parent,int mode,const char *name,V9fsSynthNode **result) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {@@ -87,8 +86,7 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add the name */ @@ -98,15 +96,13 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,v9fs_add_dir_node (node, node->attr->mode,"." , node->attr, node->attr->inode); *result = node; - ret =0 ; -return ret; +return 0 ; }int qemu_v9fs_synth_add_file (V9fsSynthNode *parent,int mode,const char *name,v9fs_synth_read read,v9fs_synth_write write,void *arg) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {@@ -122,8 +118,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add file type and remove write bits */ @@ -138,8 +133,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode, node->private = arg;pstrcpy (node->name,sizeof (node->name), name);QLIST_INSERT_HEAD_RCU (&parent->child, node, sibling); - ret =0 ; -return ret; +return 0 ; }static void synth_fill_statbuf (V9fsSynthNode *node,struct stat *stbuf)hw/char/sifive_uart.c +1
-3@@ -274,7 +274,6 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, {DeviceState *dev;SysBusDevice *s; -SiFiveUARTState *r; dev =qdev_new ("riscv.sifive.uart" ); s =SYS_BUS_DEVICE (dev);@@ -284,6 +283,5 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, sysbus_mmio_get_region(s, 0));sysbus_connect_irq (s,0 , irq); - r =SIFIVE_UART (dev); -return r; +return SIFIVE_UART (dev); }hw/ppc/ppc4xx_sdram.c +1
-4@@ -520,13 +520,10 @@ static inline hwaddr sdram_ddr2_base(uint32_t bcr)static hwaddr sdram_ddr2_size (uint32_t bcr) { -hwaddr size;int sh; sh =1024 - ((bcr >>6 ) &0x3ff ); - size =8 * MiB * sh; - -return size; +return 8 * MiB * sh; }static uint32_t sdram_ddr2_dcr_read (void *opaque,int dcrn)hw/rdma/vmw/pvrdma_cmd.c +20
-37@@ -182,13 +182,10 @@ static int create_pd(PVRDMADev *dev, union pvrdma_cmd_req *req, {struct pvrdma_cmd_create_pd *cmd = &req->create_pd;struct pvrdma_cmd_create_pd_resp *resp = &rsp->create_pd_resp; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_alloc_pd (&dev->rdma_dev_res, &dev->backend_dev, - &resp->pd_handle, cmd->ctx_handle); - -return rc; +return rdma_rm_alloc_pd (&dev->rdma_dev_res, &dev->backend_dev, + &resp->pd_handle, cmd->ctx_handle); } static int destroy_pd(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -506,20 +503,17 @@ static int modify_qp(PVRDMADev *dev, union pvrdma_cmd_req *req, union pvrdma_cmd_resp *rsp) {struct pvrdma_cmd_modify_qp *cmd = &req->modify_qp; -int rc;/* No need to verify sgid_index since it is u8 */ - rc =rdma_rm_modify_qp (&dev->rdma_dev_res, &dev->backend_dev, - cmd->qp_handle, cmd->attr_mask, - cmd->attrs.ah_attr.grh.sgid_index, - (union ibv_gid *)&cmd->attrs.ah_attr.grh.dgid, - cmd->attrs.dest_qp_num, - (enum ibv_qp_state )cmd->attrs.qp_state, - cmd->attrs.qkey, cmd->attrs.rq_psn, - cmd->attrs.sq_psn); - -return rc; +return rdma_rm_modify_qp (&dev->rdma_dev_res, &dev->backend_dev, + cmd->qp_handle, cmd->attr_mask, + cmd->attrs.ah_attr.grh.sgid_index, + (union ibv_gid *)&cmd->attrs.ah_attr.grh.dgid, + cmd->attrs.dest_qp_num, + (enum ibv_qp_state )cmd->attrs.qp_state, + cmd->attrs.qkey, cmd->attrs.rq_psn, + cmd->attrs.sq_psn); } static int query_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -528,15 +522,14 @@ static int query_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,struct pvrdma_cmd_query_qp *cmd = &req->query_qp;struct pvrdma_cmd_query_qp_resp *resp = &rsp->query_qp_resp;struct ibv_qp_init_attr init_attr; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_query_qp (&dev->rdma_dev_res, &dev->backend_dev, cmd->qp_handle, - (struct ibv_qp_attr *)&resp->attrs, cmd->attr_mask, - &init_attr); - -return rc; +return rdma_rm_query_qp (&dev->rdma_dev_res, &dev->backend_dev, + cmd->qp_handle, + (struct ibv_qp_attr *)&resp->attrs, + cmd->attr_mask, + &init_attr); } static int destroy_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -562,34 +555,27 @@ static int create_bind(PVRDMADev *dev, union pvrdma_cmd_req *req, union pvrdma_cmd_resp *rsp) {struct pvrdma_cmd_create_bind *cmd = &req->create_bind; -int rc;union ibv_gid *gid = (union ibv_gid *)&cmd->new_gid;if (cmd->index >=MAX_PORT_GIDS ) {return -EINVAL ; } - rc =rdma_rm_add_gid (&dev->rdma_dev_res, &dev->backend_dev, - dev->backend_eth_device_name, gid, cmd->index); - -return rc; +return rdma_rm_add_gid (&dev->rdma_dev_res, &dev->backend_dev, + dev->backend_eth_device_name, gid, cmd->index); }static int destroy_bind (PVRDMADev *dev,union pvrdma_cmd_req *req,union pvrdma_cmd_resp *rsp) { -int rc; -struct pvrdma_cmd_destroy_bind *cmd = &req->destroy_bind;if (cmd->index >=MAX_PORT_GIDS ) {return -EINVAL ; } - rc =rdma_rm_del_gid (&dev->rdma_dev_res, &dev->backend_dev, - dev->backend_eth_device_name, cmd->index); - -return rc; +return rdma_rm_del_gid (&dev->rdma_dev_res, &dev->backend_dev, + dev->backend_eth_device_name, cmd->index); } static int create_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -597,12 +583,9 @@ static int create_uc(PVRDMADev *dev, union pvrdma_cmd_req *req, {struct pvrdma_cmd_create_uc *cmd = &req->create_uc;struct pvrdma_cmd_create_uc_resp *resp = &rsp->create_uc_resp; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_alloc_uc (&dev->rdma_dev_res, cmd->pfn, &resp->ctx_handle); - -return rc; +return rdma_rm_alloc_uc (&dev->rdma_dev_res, cmd->pfn, &resp->ctx_handle); } static int destroy_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,hw/virtio/vhost-user.c +1
-5@@ -2532,11 +2532,7 @@ vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id)static bool vhost_user_mem_section_filter (struct vhost_dev *dev,MemoryRegionSection *section) { -bool result; - - result =memory_region_get_fd (section->mr) >=0 ; - -return result; +return memory_region_get_fd (section->mr) >=0 ; } static int vhost_user_get_inflight_fd(struct vhost_dev *dev,migration/dirtyrate.c +2
-8@@ -111,7 +111,6 @@ static void global_dirty_log_sync(unsigned int flag, bool one_shot)static DirtyPageRecord *vcpu_dirty_stat_alloc (VcpuStat *stat) {CPUState *cpu; -DirtyPageRecord *records;int nvcpu =0 ;CPU_FOREACH (cpu) {@@ -121,9 +120,7 @@ static DirtyPageRecord *vcpu_dirty_stat_alloc(VcpuStat *stat) stat->nvcpu = nvcpu; stat->rates =g_new0 (DirtyRateVcpu, nvcpu); - records =g_new0 (DirtyPageRecord, nvcpu); - -return records; +return g_new0 (DirtyPageRecord, nvcpu); } static void vcpu_dirty_stat_collect(VcpuStat *stat,@@ -473,7 +470,6 @@ find_block_matched(RAMBlock *block, int count, struct RamblockDirtyInfo *infos) {int i; -struct RamblockDirtyInfo *matched;for (i =0 ; i < count; i++) {if (!strcmp (infos[i].idstr,qemu_ram_get_idstr (block))) {@@ -492,9 +488,7 @@ find_block_matched(RAMBlock *block, int count,return NULL ; } - matched = &infos[i]; - -return matched; +return &infos[i]; } static bool compare_page_hash_info(struct RamblockDirtyInfo *info,migration/tls.c +1
-5@@ -126,7 +126,6 @@ QIOChannelTLS *migration_tls_client_create(MigrationState *s, Error **errp) {QCryptoTLSCreds *creds; -QIOChannelTLS *tioc; creds =migration_tls_get_creds ( s,QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT , errp);@@ -138,10 +137,7 @@ QIOChannelTLS *migration_tls_client_create(MigrationState *s, hostname = s->parameters.tls_hostname; } - tioc =qio_channel_tls_new_client ( - ioc, creds, hostname, errp); - -return tioc; +return qio_channel_tls_new_client (ioc, creds, hostname, errp); } void migration_tls_channel_connect(MigrationState *s,replay/replay-time.c +1
-4@@ -48,7 +48,6 @@ void replay_read_next_clock(ReplayClockKind kind)/*! Reads next clock event from the input. */ int64_t replay_read_clock (ReplayClockKind kind,int64_t raw_icount) { -int64_t ret;g_assert (replay_file &&replay_mutex_locked ());replay_advance_current_icount (raw_icount);@@ -56,7 +55,5 @@ int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount)if (replay_next_event_is (EVENT_CLOCK + kind)) {replay_read_next_clock (kind); } - ret = replay_state.cached_clock[kind]; - -return ret; +return replay_state.cached_clock[kind]; }semihosting/console.c +1
-3@@ -43,10 +43,8 @@ static SemihostingConsole console;static int console_can_read (void *opaque) {SemihostingConsole *c = opaque; -int ret;g_assert (qemu_mutex_iothread_locked ()); - ret = (int )fifo8_num_free (&c->fifo); -return ret; +return (int )fifo8_num_free (&c->fifo); }static void console_wake_up (gpointer data,gpointer user_data)softmmu/memory.c +2
-9@@ -2372,20 +2372,15 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,int memory_region_get_fd (MemoryRegion *mr) { -int fd; -RCU_READ_LOCK_GUARD ();while (mr->alias) { mr = mr->alias; } - fd = mr->ram_block->fd; - -return fd; +return mr->ram_block->fd; }void *memory_region_get_ram_ptr (MemoryRegion *mr) { -void *ptr;uint64_t offset =0 ;RCU_READ_LOCK_GUARD ();@@ -2394,9 +2389,7 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr) mr = mr->alias; }assert (mr->ram_block); - ptr =qemu_map_ram_ptr (mr->ram_block, offset); - -return ptr; +return qemu_map_ram_ptr (mr->ram_block, offset); }MemoryRegion *memory_region_from_host (void *ptr,ram_addr_t *offset)softmmu/physmem.c +2
-7@@ -3236,7 +3236,6 @@ void *address_space_map(AddressSpace *as,hwaddr len = *plen;hwaddr l, xlat;MemoryRegion *mr; -void *ptr;FlatView *fv;if (len ==0 ) {@@ -3275,9 +3274,7 @@ void *address_space_map(AddressSpace *as, *plen =flatview_extend_translation (fv, addr, len, mr, xlat, l, is_write, attrs);fuzz_dma_read_cb (addr, *plen, mr); - ptr =qemu_ram_ptr_length (mr->ram_block, xlat, plen, true); - -return ptr; +return qemu_ram_ptr_length (mr->ram_block, xlat, plen, true); }/* Unmaps a memory region previously mapped by address_space_map(). @@ -3545,15 +3542,13 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) {MemoryRegion *mr;hwaddr l =1 ; -bool res;RCU_READ_LOCK_GUARD (); mr =address_space_translate (&address_space_memory, phys_addr, &phys_addr, &l, false,MEMTXATTRS_UNSPECIFIED ); - res = !(memory_region_is_ram (mr) ||memory_region_is_romd (mr)); -return res; +return !(memory_region_is_ram (mr) ||memory_region_is_romd (mr)); }int qemu_ram_foreach_block (RAMBlockIterFunc func,void *opaque)target/loongarch/cpu.c +1
-3@@ -128,13 +128,11 @@ static inline bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env) {uint32_t pending;uint32_t status; -bool r; pending =FIELD_EX64 (env->CSR_ESTAT,CSR_ESTAT ,IS ); status =FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,LIE ); - r = (pending & status) !=0 ; -return r; +return (pending & status) !=0 ; }static void loongarch_cpu_do_interrupt (CPUState *cs)target/mips/tcg/dsp_helper.c +3
-12@@ -3281,15 +3281,12 @@ target_ulong helper_dextr_l(target_ulong ac, target_ulong shift, CPUMIPSState *env) {uint64_t temp[3 ]; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env); - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); } target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,@@ -3297,7 +3294,6 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift, {uint64_t temp[3 ];uint32_t temp128; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env);@@ -3317,9 +3313,7 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,set_DSPControl_overflow_flag (1 ,23 , env); } - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); } target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift,@@ -3327,7 +3321,6 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift, {uint64_t temp[3 ];uint32_t temp128; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env);@@ -3354,9 +3347,7 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift, set_DSPControl_overflow_flag(1, 23, env); } - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); }#endif target/riscv/debug.c +2
-4@@ -243,15 +243,13 @@ static void do_trigger_action(CPURISCVState *env, target_ulong trigger_index)static uint32_t type2_breakpoint_size (CPURISCVState *env,target_ulong ctrl) { -uint32_t size, sizelo, sizehi =0 ; +uint32_t sizelo, sizehi =0 ;if (riscv_cpu_mxl (env) ==MXL_RV64 ) { sizehi =extract32 (ctrl,21 ,2 ); } sizelo =extract32 (ctrl,16 ,2 ); - size = (sizehi <<2 ) | sizelo; - -return size; +return (sizehi <<2 ) | sizelo; }static inline bool type2_breakpoint_enabled (target_ulong ctrl)target/riscv/vector_helper.c +7
-21@@ -2791,31 +2791,25 @@ static inline uint16_t vssrl16(CPURISCVState *env, int vxrm, uint16_t a, uint16_t b) {uint8_t round, shift = b &0xf ; -uint16_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline uint32_t vssrl32 (CPURISCVState *env,int vxrm,uint32_t a,uint32_t b) {uint8_t round, shift = b &0x1f ; -uint32_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline uint64_t vssrl64 (CPURISCVState *env,int vxrm,uint64_t a,uint64_t b) {uint8_t round, shift = b &0x3f ; -uint64_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; } RVVCALL(OPIVV2_RM, vssrl_vv_b, OP_UUU_B, H1, H1, H1, vssrl8)RVVCALL (OPIVV2_RM , vssrl_vv_h,OP_UUU_H ,H2 ,H2 ,H2 , vssrl16)@@ -2839,41 +2833,33 @@ static inline int8_t vssra8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) {uint8_t round, shift = b &0x7 ; -int8_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int16_t vssra16 (CPURISCVState *env,int vxrm,int16_t a,int16_t b) {uint8_t round, shift = b &0xf ; -int16_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int32_t vssra32 (CPURISCVState *env,int vxrm,int32_t a,int32_t b) {uint8_t round, shift = b &0x1f ; -int32_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int64_t vssra64 (CPURISCVState *env,int vxrm,int64_t a,int64_t b) {uint8_t round, shift = b &0x3f ; -int64_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }RVVCALL (OPIVV2_RM , vssra_vv_b,OP_SSS_B ,H1 ,H1 ,H1 , vssra8)tests/bench/benchmark-crypto-akcipher.c +2
-4@@ -24,14 +24,12 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, QCryptoHashAlgorithm hash) {QCryptoAkCipherOptions opt; -QCryptoAkCipher *rsa; opt.alg =QCRYPTO_AKCIPHER_ALG_RSA ; opt.u.rsa.padding_alg = padding; opt.u.rsa.hash_alg = hash; - rsa =qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , - priv_key, keylen, &error_abort); -return rsa; +return qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , + priv_key, keylen, &error_abort); } static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,tests/qtest/erst-test.c +1
-4@@ -154,10 +154,7 @@ static void test_acpi_erst_basic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/acpi-erst/basic" , test_acpi_erst_basic); - ret =g_test_run (); -return ret; +return g_test_run (); }tests/qtest/hexloader-test.c +1
-5@@ -34,12 +34,8 @@ static void hex_loader_test(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/tmp/hex_loader" , hex_loader_test); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/pvpanic-pci-test.c +1
-5@@ -86,13 +86,9 @@ static void test_panic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic-pci/panic" , test_panic);qtest_add_func ("/pvpanic-pci/panic-nopause" , test_panic_nopause); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/pvpanic-test.c +1
-5@@ -59,13 +59,9 @@ static void test_panic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic/panic" , test_panic);qtest_add_func ("/pvpanic/panic-nopause" , test_panic_nopause); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/test-filter-mirror.c +1
-5@@ -76,12 +76,8 @@ static void test_mirror(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/netfilter/mirror" , test_mirror); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/virtio-ccw-test.c +1
-5@@ -95,8 +95,6 @@ static void virtio_scsi_hotplug(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/virtio/balloon/nop" , virtio_balloon_nop);qtest_add_func ("/virtio/console/nop" , virtconsole_nop);@@ -109,7 +107,5 @@ int main(int argc, char **argv)qtest_add_func ("/virtio/scsi/nop" , virtio_scsi_nop);qtest_add_func ("/virtio/scsi/hotplug" , virtio_scsi_hotplug); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/tcg/multiarch/sha512.c +2
-7@@ -855,8 +855,6 @@ plan_tests(unsigned int tests)static int exit_status_ (void ) { -int r; -/* If there's no plan, just return the number of failures */ if (no_plan || !have_plan) {return failures;@@ -865,15 +863,12 @@ exit_status_(void)/* Ran too many tests? Return the number of tests that were run that shouldn't have been */ if (e_tests < test_count) { - r = test_count - e_tests; -return r; +return test_count - e_tests; }/* Return the number of tests that failed + the number of tests that weren't run */ - r = failures + e_tests - test_count; - -return r; +return failures + e_tests - test_count; }int tools/virtiofsd/fuse_lowlevel.c +6
-18@@ -216,7 +216,6 @@ static int send_reply(fuse_req_t req, int error, const void *arg,int fuse_reply_iov (fuse_req_t req,const struct iovec *iov,int count) { -int res; g_autofree struct iovec *padded_iov = NULL; padded_iov = g_try_new(struct iovec, count + 1);@@ -227,9 +226,7 @@ int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)memcpy (padded_iov +1 , iov, count *sizeof (struct iovec )); count++; - res =send_reply_iov (req,0 , padded_iov, count); - -return res; +return send_reply_iov (req,0 , padded_iov, count); }@@ -589,7 +586,6 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov, g_autofree struct fuse_ioctl_iovec *out_fiov = NULL;struct iovec iov[4 ];size_t count =1 ; -int res;memset (&arg,0 ,sizeof (arg)); arg.flags |=FUSE_IOCTL_RETRY ;@@ -601,15 +597,13 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,/* Can't handle non-compat 64bit ioctls on 32bit */ if (sizeof (void *) ==4 && req->ioctl_64bit) { - res =fuse_reply_err (req,EINVAL ); -return res; +return fuse_reply_err (req,EINVAL ); }if (in_count) { in_fiov =fuse_ioctl_iovec_copy (in_iov, in_count);if (!in_fiov) { - res =fuse_reply_err (req,ENOMEM ); -return res; +return fuse_reply_err (req,ENOMEM ); } iov[count].iov_base = (void *)in_fiov;@@ -619,8 +613,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,if (out_count) { out_fiov =fuse_ioctl_iovec_copy (out_iov, out_count);if (!out_fiov) { - res =fuse_reply_err (req,ENOMEM ); -return res; +return fuse_reply_err (req,ENOMEM ); } iov[count].iov_base = (void *)out_fiov;@@ -628,9 +621,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov, count++; } - res =send_reply_iov (req,0 , iov, count); - -return res; +return send_reply_iov (req,0 , iov, count); }int fuse_reply_ioctl (fuse_req_t req,int result,const void *buf,size_t size)@@ -659,7 +650,6 @@ int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov, { g_autofree struct iovec *padded_iov = NULL;struct fuse_ioctl_out arg; -int res; padded_iov = g_try_new(struct iovec, count + 2);if (padded_iov ==NULL ) {@@ -673,9 +663,7 @@ int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov,memcpy (&padded_iov[2 ], iov, count *sizeof (struct iovec )); - res =send_reply_iov (req,0 , padded_iov, count +2 ); - -return res; +return send_reply_iov (req,0 , padded_iov, count +2 ); }int fuse_reply_poll (fuse_req_t req,unsigned revents)Signature · 1 line
2.37.3
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 9 lines · On Tue, 22 Nov 2022 14:49:16 +0100 Markus Armbruster <[email protected]> wrote:
Tweak the semantic patch to drop redundant parenthesis around the return expression.
Coccinelle drops a comment in
hw/rdma/vmw/pvrdma_cmd.c; restored manually.Coccinelle messes up
vmdk_co_create(), not sure why. Change dropped, will be done manually in the next commit.
Quoted 9 lines
Line breaks in
target/avr/cpu.handhw/rdma/vmw/pvrdma_cmd.ctidied up manually.Whitespace in
tools/virtiofsd/fuse_lowlevel.ctidied up manually.checkpatch.pl complains "return of an errno should typically be -ve" two times for
hw/9pfs/9p-synth.c. Preexisting, the patch merely makes it visible to checkpatch.pl.
Hi Markus,
Yeah these positive errno values have been sitting there since the beginning. It was dead code until I hijacked the synth backend to implement qtest for 9p. I didn't care much about the return value of the two culprits at the time since both are passed to assert(!ret) right away. For this reason, changing the sign should be easy :-)
I see that checkpatch.pl considers this as an error. I'll post a fix. I guess you'll need to rebase on this fix for your patches to pass CI.
Anyway, for 9p:
Quoted 943 lines
Signed-off-by Markus Armbruster <[email protected]>--- scripts/coccinelle/return_directly.cocci | 5 +-- include/hw/pci/pci.h | 7 +-- target/avr/cpu.h | 4 +- hw/9pfs/9p-synth.c | 14 ++---- hw/char/sifive_uart.c | 4 +- hw/ppc/ppc4xx_sdram.c | 5 +-- hw/rdma/vmw/pvrdma_cmd.c | 57 +++++++++--------------- hw/virtio/vhost-user.c | 6 +-- migration/dirtyrate.c | 10 +---- migration/tls.c | 6 +-- replay/replay-time.c | 5 +-- semihosting/console.c | 4 +- softmmu/memory.c | 11 +---- softmmu/physmem.c | 9 +--- target/loongarch/cpu.c | 4 +- target/mips/tcg/dsp_helper.c | 15 ++----- target/riscv/debug.c | 6 +-- target/riscv/vector_helper.c | 28 +++--------- tests/bench/benchmark-crypto-akcipher.c | 6 +-- tests/qtest/erst-test.c | 5 +-- tests/qtest/hexloader-test.c | 6 +-- tests/qtest/pvpanic-pci-test.c | 6 +-- tests/qtest/pvpanic-test.c | 6 +-- tests/qtest/test-filter-mirror.c | 6 +-- tests/qtest/virtio-ccw-test.c | 6 +-- tests/tcg/multiarch/sha512.c | 9 +--- tools/virtiofsd/fuse_lowlevel.c | 24 +++------- 27 files changed, 70 insertions(+), 204 deletions(-)scripts/coccinelle/return_directly.cocci +2
-3@@ -11,9 +11,8 @@ identifier F; - T VAR; ... when != VAR -- VAR = -+ return - E; +- VAR = (E); - return VAR; ++ return E; ... when != VAR }include/hw/pci/pci.h +2
-5@@ -921,11 +921,8 @@ PCI_DMA_DEFINE_LDST(q_be, q_be, 64);static inline void *pci_dma_map (PCIDevice *dev,dma_addr_t addr,dma_addr_t *plen,DMADirection dir) { -void *buf; - - buf =dma_memory_map (pci_get_address_space (dev), addr, plen, dir, -MEMTXATTRS_UNSPECIFIED ); -return buf; +return dma_memory_map (pci_get_address_space (dev), addr, plen, dir, +MEMTXATTRS_UNSPECIFIED ); } static inline void pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len,target/avr/cpu.h +1
-3@@ -215,8 +215,7 @@ static inline int cpu_interrupts_enabled(CPUAVRState *env)static inline uint8_t cpu_get_sreg (CPUAVRState *env) { -uint8_t sreg; - sreg = (env->sregC) <<0 +return (env->sregC) <<0 | (env->sregZ) <<1 | (env->sregN) <<2 | (env->sregV) <<3 @@ -224,7 +223,6 @@ static inline uint8_t cpu_get_sreg(CPUAVRState *env) | (env->sregH) << 5 | (env->sregT) <<6 | (env->sregI) <<7 ; -return sreg; }static inline void cpu_set_sreg (CPUAVRState *env,uint8_t sreg)hw/9pfs/9p-synth.c +4
-10@@ -72,7 +72,6 @@ static V9fsSynthNode *v9fs_add_dir_node(V9fsSynthNode *parent, int mode,int qemu_v9fs_synth_mkdir (V9fsSynthNode *parent,int mode,const char *name,V9fsSynthNode **result) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {@@ -87,8 +86,7 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add the name */ @@ -98,15 +96,13 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,v9fs_add_dir_node (node, node->attr->mode,"." , node->attr, node->attr->inode); *result = node; - ret =0 ; -return ret; +return 0 ; }int qemu_v9fs_synth_add_file (V9fsSynthNode *parent,int mode,const char *name,v9fs_synth_read read,v9fs_synth_write write,void *arg) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {@@ -122,8 +118,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add file type and remove write bits */ @@ -138,8 +133,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode, node->private = arg;pstrcpy (node->name,sizeof (node->name), name);QLIST_INSERT_HEAD_RCU (&parent->child, node, sibling); - ret =0 ; -return ret; +return 0 ; }static void synth_fill_statbuf (V9fsSynthNode *node,struct stat *stbuf)hw/char/sifive_uart.c +1
-3@@ -274,7 +274,6 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, {DeviceState *dev;SysBusDevice *s; -SiFiveUARTState *r; dev =qdev_new ("riscv.sifive.uart" ); s =SYS_BUS_DEVICE (dev);@@ -284,6 +283,5 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, sysbus_mmio_get_region(s, 0));sysbus_connect_irq (s,0 , irq); - r =SIFIVE_UART (dev); -return r; +return SIFIVE_UART (dev); }hw/ppc/ppc4xx_sdram.c +1
-4@@ -520,13 +520,10 @@ static inline hwaddr sdram_ddr2_base(uint32_t bcr)static hwaddr sdram_ddr2_size (uint32_t bcr) { -hwaddr size;int sh; sh =1024 - ((bcr >>6 ) &0x3ff ); - size =8 * MiB * sh; - -return size; +return 8 * MiB * sh; }static uint32_t sdram_ddr2_dcr_read (void *opaque,int dcrn)hw/rdma/vmw/pvrdma_cmd.c +20
-37@@ -182,13 +182,10 @@ static int create_pd(PVRDMADev *dev, union pvrdma_cmd_req *req, {struct pvrdma_cmd_create_pd *cmd = &req->create_pd;struct pvrdma_cmd_create_pd_resp *resp = &rsp->create_pd_resp; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_alloc_pd (&dev->rdma_dev_res, &dev->backend_dev, - &resp->pd_handle, cmd->ctx_handle); - -return rc; +return rdma_rm_alloc_pd (&dev->rdma_dev_res, &dev->backend_dev, + &resp->pd_handle, cmd->ctx_handle); } static int destroy_pd(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -506,20 +503,17 @@ static int modify_qp(PVRDMADev *dev, union pvrdma_cmd_req *req, union pvrdma_cmd_resp *rsp) {struct pvrdma_cmd_modify_qp *cmd = &req->modify_qp; -int rc;/* No need to verify sgid_index since it is u8 */ - rc =rdma_rm_modify_qp (&dev->rdma_dev_res, &dev->backend_dev, - cmd->qp_handle, cmd->attr_mask, - cmd->attrs.ah_attr.grh.sgid_index, - (union ibv_gid *)&cmd->attrs.ah_attr.grh.dgid, - cmd->attrs.dest_qp_num, - (enum ibv_qp_state )cmd->attrs.qp_state, - cmd->attrs.qkey, cmd->attrs.rq_psn, - cmd->attrs.sq_psn); - -return rc; +return rdma_rm_modify_qp (&dev->rdma_dev_res, &dev->backend_dev, + cmd->qp_handle, cmd->attr_mask, + cmd->attrs.ah_attr.grh.sgid_index, + (union ibv_gid *)&cmd->attrs.ah_attr.grh.dgid, + cmd->attrs.dest_qp_num, + (enum ibv_qp_state )cmd->attrs.qp_state, + cmd->attrs.qkey, cmd->attrs.rq_psn, + cmd->attrs.sq_psn); } static int query_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -528,15 +522,14 @@ static int query_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,struct pvrdma_cmd_query_qp *cmd = &req->query_qp;struct pvrdma_cmd_query_qp_resp *resp = &rsp->query_qp_resp;struct ibv_qp_init_attr init_attr; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_query_qp (&dev->rdma_dev_res, &dev->backend_dev, cmd->qp_handle, - (struct ibv_qp_attr *)&resp->attrs, cmd->attr_mask, - &init_attr); - -return rc; +return rdma_rm_query_qp (&dev->rdma_dev_res, &dev->backend_dev, + cmd->qp_handle, + (struct ibv_qp_attr *)&resp->attrs, + cmd->attr_mask, + &init_attr); } static int destroy_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -562,34 +555,27 @@ static int create_bind(PVRDMADev *dev, union pvrdma_cmd_req *req, union pvrdma_cmd_resp *rsp) {struct pvrdma_cmd_create_bind *cmd = &req->create_bind; -int rc;union ibv_gid *gid = (union ibv_gid *)&cmd->new_gid;if (cmd->index >=MAX_PORT_GIDS ) {return -EINVAL ; } - rc =rdma_rm_add_gid (&dev->rdma_dev_res, &dev->backend_dev, - dev->backend_eth_device_name, gid, cmd->index); - -return rc; +return rdma_rm_add_gid (&dev->rdma_dev_res, &dev->backend_dev, + dev->backend_eth_device_name, gid, cmd->index); }static int destroy_bind (PVRDMADev *dev,union pvrdma_cmd_req *req,union pvrdma_cmd_resp *rsp) { -int rc; -struct pvrdma_cmd_destroy_bind *cmd = &req->destroy_bind;if (cmd->index >=MAX_PORT_GIDS ) {return -EINVAL ; } - rc =rdma_rm_del_gid (&dev->rdma_dev_res, &dev->backend_dev, - dev->backend_eth_device_name, cmd->index); - -return rc; +return rdma_rm_del_gid (&dev->rdma_dev_res, &dev->backend_dev, + dev->backend_eth_device_name, cmd->index); } static int create_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -597,12 +583,9 @@ static int create_uc(PVRDMADev *dev, union pvrdma_cmd_req *req, {struct pvrdma_cmd_create_uc *cmd = &req->create_uc;struct pvrdma_cmd_create_uc_resp *resp = &rsp->create_uc_resp; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_alloc_uc (&dev->rdma_dev_res, cmd->pfn, &resp->ctx_handle); - -return rc; +return rdma_rm_alloc_uc (&dev->rdma_dev_res, cmd->pfn, &resp->ctx_handle); } static int destroy_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,hw/virtio/vhost-user.c +1
-5@@ -2532,11 +2532,7 @@ vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id)static bool vhost_user_mem_section_filter (struct vhost_dev *dev,MemoryRegionSection *section) { -bool result; - - result =memory_region_get_fd (section->mr) >=0 ; - -return result; +return memory_region_get_fd (section->mr) >=0 ; } static int vhost_user_get_inflight_fd(struct vhost_dev *dev,migration/dirtyrate.c +2
-8@@ -111,7 +111,6 @@ static void global_dirty_log_sync(unsigned int flag, bool one_shot)static DirtyPageRecord *vcpu_dirty_stat_alloc (VcpuStat *stat) {CPUState *cpu; -DirtyPageRecord *records;int nvcpu =0 ;CPU_FOREACH (cpu) {@@ -121,9 +120,7 @@ static DirtyPageRecord *vcpu_dirty_stat_alloc(VcpuStat *stat) stat->nvcpu = nvcpu; stat->rates =g_new0 (DirtyRateVcpu, nvcpu); - records =g_new0 (DirtyPageRecord, nvcpu); - -return records; +return g_new0 (DirtyPageRecord, nvcpu); } static void vcpu_dirty_stat_collect(VcpuStat *stat,@@ -473,7 +470,6 @@ find_block_matched(RAMBlock *block, int count, struct RamblockDirtyInfo *infos) {int i; -struct RamblockDirtyInfo *matched;for (i =0 ; i < count; i++) {if (!strcmp (infos[i].idstr,qemu_ram_get_idstr (block))) {@@ -492,9 +488,7 @@ find_block_matched(RAMBlock *block, int count,return NULL ; } - matched = &infos[i]; - -return matched; +return &infos[i]; } static bool compare_page_hash_info(struct RamblockDirtyInfo *info,migration/tls.c +1
-5@@ -126,7 +126,6 @@ QIOChannelTLS *migration_tls_client_create(MigrationState *s, Error **errp) {QCryptoTLSCreds *creds; -QIOChannelTLS *tioc; creds =migration_tls_get_creds ( s,QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT , errp);@@ -138,10 +137,7 @@ QIOChannelTLS *migration_tls_client_create(MigrationState *s, hostname = s->parameters.tls_hostname; } - tioc =qio_channel_tls_new_client ( - ioc, creds, hostname, errp); - -return tioc; +return qio_channel_tls_new_client (ioc, creds, hostname, errp); } void migration_tls_channel_connect(MigrationState *s,replay/replay-time.c +1
-4@@ -48,7 +48,6 @@ void replay_read_next_clock(ReplayClockKind kind)/*! Reads next clock event from the input. */ int64_t replay_read_clock (ReplayClockKind kind,int64_t raw_icount) { -int64_t ret;g_assert (replay_file &&replay_mutex_locked ());replay_advance_current_icount (raw_icount);@@ -56,7 +55,5 @@ int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount)if (replay_next_event_is (EVENT_CLOCK + kind)) {replay_read_next_clock (kind); } - ret = replay_state.cached_clock[kind]; - -return ret; +return replay_state.cached_clock[kind]; }semihosting/console.c +1
-3@@ -43,10 +43,8 @@ static SemihostingConsole console;static int console_can_read (void *opaque) {SemihostingConsole *c = opaque; -int ret;g_assert (qemu_mutex_iothread_locked ()); - ret = (int )fifo8_num_free (&c->fifo); -return ret; +return (int )fifo8_num_free (&c->fifo); }static void console_wake_up (gpointer data,gpointer user_data)softmmu/memory.c +2
-9@@ -2372,20 +2372,15 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,int memory_region_get_fd (MemoryRegion *mr) { -int fd; -RCU_READ_LOCK_GUARD ();while (mr->alias) { mr = mr->alias; } - fd = mr->ram_block->fd; - -return fd; +return mr->ram_block->fd; }void *memory_region_get_ram_ptr (MemoryRegion *mr) { -void *ptr;uint64_t offset =0 ;RCU_READ_LOCK_GUARD ();@@ -2394,9 +2389,7 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr) mr = mr->alias; }assert (mr->ram_block); - ptr =qemu_map_ram_ptr (mr->ram_block, offset); - -return ptr; +return qemu_map_ram_ptr (mr->ram_block, offset); }MemoryRegion *memory_region_from_host (void *ptr,ram_addr_t *offset)softmmu/physmem.c +2
-7@@ -3236,7 +3236,6 @@ void *address_space_map(AddressSpace *as,hwaddr len = *plen;hwaddr l, xlat;MemoryRegion *mr; -void *ptr;FlatView *fv;if (len ==0 ) {@@ -3275,9 +3274,7 @@ void *address_space_map(AddressSpace *as, *plen =flatview_extend_translation (fv, addr, len, mr, xlat, l, is_write, attrs);fuzz_dma_read_cb (addr, *plen, mr); - ptr =qemu_ram_ptr_length (mr->ram_block, xlat, plen, true); - -return ptr; +return qemu_ram_ptr_length (mr->ram_block, xlat, plen, true); }/* Unmaps a memory region previously mapped by address_space_map(). @@ -3545,15 +3542,13 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) {MemoryRegion *mr;hwaddr l =1 ; -bool res;RCU_READ_LOCK_GUARD (); mr =address_space_translate (&address_space_memory, phys_addr, &phys_addr, &l, false,MEMTXATTRS_UNSPECIFIED ); - res = !(memory_region_is_ram (mr) ||memory_region_is_romd (mr)); -return res; +return !(memory_region_is_ram (mr) ||memory_region_is_romd (mr)); }int qemu_ram_foreach_block (RAMBlockIterFunc func,void *opaque)target/loongarch/cpu.c +1
-3@@ -128,13 +128,11 @@ static inline bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env) {uint32_t pending;uint32_t status; -bool r; pending =FIELD_EX64 (env->CSR_ESTAT,CSR_ESTAT ,IS ); status =FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,LIE ); - r = (pending & status) !=0 ; -return r; +return (pending & status) !=0 ; }static void loongarch_cpu_do_interrupt (CPUState *cs)target/mips/tcg/dsp_helper.c +3
-12@@ -3281,15 +3281,12 @@ target_ulong helper_dextr_l(target_ulong ac, target_ulong shift, CPUMIPSState *env) {uint64_t temp[3 ]; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env); - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); } target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,@@ -3297,7 +3294,6 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift, {uint64_t temp[3 ];uint32_t temp128; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env);@@ -3317,9 +3313,7 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,set_DSPControl_overflow_flag (1 ,23 , env); } - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); } target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift,@@ -3327,7 +3321,6 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift, {uint64_t temp[3 ];uint32_t temp128; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env);@@ -3354,9 +3347,7 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift, set_DSPControl_overflow_flag(1, 23, env); } - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); }#endif target/riscv/debug.c +2
-4@@ -243,15 +243,13 @@ static void do_trigger_action(CPURISCVState *env, target_ulong trigger_index)static uint32_t type2_breakpoint_size (CPURISCVState *env,target_ulong ctrl) { -uint32_t size, sizelo, sizehi =0 ; +uint32_t sizelo, sizehi =0 ;if (riscv_cpu_mxl (env) ==MXL_RV64 ) { sizehi =extract32 (ctrl,21 ,2 ); } sizelo =extract32 (ctrl,16 ,2 ); - size = (sizehi <<2 ) | sizelo; - -return size; +return (sizehi <<2 ) | sizelo; }static inline bool type2_breakpoint_enabled (target_ulong ctrl)target/riscv/vector_helper.c +7
-21@@ -2791,31 +2791,25 @@ static inline uint16_t vssrl16(CPURISCVState *env, int vxrm, uint16_t a, uint16_t b) {uint8_t round, shift = b &0xf ; -uint16_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline uint32_t vssrl32 (CPURISCVState *env,int vxrm,uint32_t a,uint32_t b) {uint8_t round, shift = b &0x1f ; -uint32_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline uint64_t vssrl64 (CPURISCVState *env,int vxrm,uint64_t a,uint64_t b) {uint8_t round, shift = b &0x3f ; -uint64_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; } RVVCALL(OPIVV2_RM, vssrl_vv_b, OP_UUU_B, H1, H1, H1, vssrl8)RVVCALL (OPIVV2_RM , vssrl_vv_h,OP_UUU_H ,H2 ,H2 ,H2 , vssrl16)@@ -2839,41 +2833,33 @@ static inline int8_t vssra8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) {uint8_t round, shift = b &0x7 ; -int8_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int16_t vssra16 (CPURISCVState *env,int vxrm,int16_t a,int16_t b) {uint8_t round, shift = b &0xf ; -int16_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int32_t vssra32 (CPURISCVState *env,int vxrm,int32_t a,int32_t b) {uint8_t round, shift = b &0x1f ; -int32_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int64_t vssra64 (CPURISCVState *env,int vxrm,int64_t a,int64_t b) {uint8_t round, shift = b &0x3f ; -int64_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }RVVCALL (OPIVV2_RM , vssra_vv_b,OP_SSS_B ,H1 ,H1 ,H1 , vssra8)tests/bench/benchmark-crypto-akcipher.c +2
-4@@ -24,14 +24,12 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, QCryptoHashAlgorithm hash) {QCryptoAkCipherOptions opt; -QCryptoAkCipher *rsa; opt.alg =QCRYPTO_AKCIPHER_ALG_RSA ; opt.u.rsa.padding_alg = padding; opt.u.rsa.hash_alg = hash; - rsa =qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , - priv_key, keylen, &error_abort); -return rsa; +return qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , + priv_key, keylen, &error_abort); } static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,tests/qtest/erst-test.c +1
-4@@ -154,10 +154,7 @@ static void test_acpi_erst_basic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/acpi-erst/basic" , test_acpi_erst_basic); - ret =g_test_run (); -return ret; +return g_test_run (); }tests/qtest/hexloader-test.c +1
-5@@ -34,12 +34,8 @@ static void hex_loader_test(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/tmp/hex_loader" , hex_loader_test); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/pvpanic-pci-test.c +1
-5@@ -86,13 +86,9 @@ static void test_panic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic-pci/panic" , test_panic);qtest_add_func ("/pvpanic-pci/panic-nopause" , test_panic_nopause); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/pvpanic-test.c +1
-5@@ -59,13 +59,9 @@ static void test_panic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic/panic" , test_panic);qtest_add_func ("/pvpanic/panic-nopause" , test_panic_nopause); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/test-filter-mirror.c +1
-5@@ -76,12 +76,8 @@ static void test_mirror(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/netfilter/mirror" , test_mirror); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/virtio-ccw-test.c +1
-5@@ -95,8 +95,6 @@ static void virtio_scsi_hotplug(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/virtio/balloon/nop" , virtio_balloon_nop);qtest_add_func ("/virtio/console/nop" , virtconsole_nop);@@ -109,7 +107,5 @@ int main(int argc, char **argv)qtest_add_func ("/virtio/scsi/nop" , virtio_scsi_nop);qtest_add_func ("/virtio/scsi/hotplug" , virtio_scsi_hotplug); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/tcg/multiarch/sha512.c +2
-7@@ -855,8 +855,6 @@ plan_tests(unsigned int tests)static int exit_status_ (void ) { -int r; -/* If there's no plan, just return the number of failures */ if (no_plan || !have_plan) {return failures;@@ -865,15 +863,12 @@ exit_status_(void)/* Ran too many tests? Return the number of tests that were run that shouldn't have been */ if (e_tests < test_count) { - r = test_count - e_tests; -return r; +return test_count - e_tests; }/* Return the number of tests that failed + the number of tests that weren't run */ - r = failures + e_tests - test_count; - -return r; +return failures + e_tests - test_count; }int tools/virtiofsd/fuse_lowlevel.c +6
-18@@ -216,7 +216,6 @@ static int send_reply(fuse_req_t req, int error, const void *arg,int fuse_reply_iov (fuse_req_t req,const struct iovec *iov,int count) { -int res; g_autofree struct iovec *padded_iov = NULL; padded_iov = g_try_new(struct iovec, count + 1);@@ -227,9 +226,7 @@ int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)memcpy (padded_iov +1 , iov, count *sizeof (struct iovec )); count++; - res =send_reply_iov (req,0 , padded_iov, count); - -return res; +return send_reply_iov (req,0 , padded_iov, count); }@@ -589,7 +586,6 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov, g_autofree struct fuse_ioctl_iovec *out_fiov = NULL;struct iovec iov[4 ];size_t count =1 ; -int res;memset (&arg,0 ,sizeof (arg)); arg.flags |=FUSE_IOCTL_RETRY ;@@ -601,15 +597,13 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,/* Can't handle non-compat 64bit ioctls on 32bit */ if (sizeof (void *) ==4 && req->ioctl_64bit) { - res =fuse_reply_err (req,EINVAL ); -return res; +return fuse_reply_err (req,EINVAL ); }if (in_count) { in_fiov =fuse_ioctl_iovec_copy (in_iov, in_count);if (!in_fiov) { - res =fuse_reply_err (req,ENOMEM ); -return res; +return fuse_reply_err (req,ENOMEM ); } iov[count].iov_base = (void *)in_fiov;@@ -619,8 +613,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,if (out_count) { out_fiov =fuse_ioctl_iovec_copy (out_iov, out_count);if (!out_fiov) { - res =fuse_reply_err (req,ENOMEM ); -return res; +return fuse_reply_err (req,ENOMEM ); } iov[count].iov_base = (void *)out_fiov;@@ -628,9 +621,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov, count++; } - res =send_reply_iov (req,0 , iov, count); - -return res; +return send_reply_iov (req,0 , iov, count); }int fuse_reply_ioctl (fuse_req_t req,int result,const void *buf,size_t size)@@ -659,7 +650,6 @@ int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov, { g_autofree struct iovec *padded_iov = NULL;struct fuse_ioctl_out arg; -int res; padded_iov = g_try_new(struct iovec, count + 2);if (padded_iov ==NULL ) {@@ -673,9 +663,7 @@ int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov,memcpy (&padded_iov[2 ], iov, count *sizeof (struct iovec )); - res =send_reply_iov (req,0 , padded_iov, count +2 ); - -return res; +return send_reply_iov (req,0 , padded_iov, count +2 ); }int fuse_reply_poll (fuse_req_t req,unsigned revents)
Quoted 30 lines · On Thu, 24 Nov 2022 16:15:11 +0100 Greg Kurz <[email protected]> wrote:
Quoted 9 lines · On Tue, 22 Nov 2022 14:49:16 +0100 Markus Armbruster <[email protected]> wrote:
Tweak the semantic patch to drop redundant parenthesis around the return expression.
Coccinelle drops a comment in
hw/rdma/vmw/pvrdma_cmd.c; restored manually.Coccinelle messes up
vmdk_co_create(), not sure why. Change dropped, will be done manually in the next commit.Quoted 9 lines
Line breaks in
target/avr/cpu.handhw/rdma/vmw/pvrdma_cmd.ctidied up manually.Whitespace in
tools/virtiofsd/fuse_lowlevel.ctidied up manually.checkpatch.pl complains "return of an errno should typically be -ve" two times for
hw/9pfs/9p-synth.c. Preexisting, the patch merely makes it visible to checkpatch.pl.Hi Markus,
Yeah these positive errno values have been sitting there since the beginning. It was dead code until I hijacked the synth backend to implement qtest for 9p. I didn't care much about the return value of the two culprits at the time since both are passed to assert(!ret) right away. For this reason, changing the sign should be easy :-)
Quoted 4 lines
I see that checkpatch.pl considers this as an error. I'll post a fix. I guess you'll need to rebase on this fix for your patches to pass CI.
Or maybe I can fix the issues detected by coccinelle as well and you can just drop the 9p bits from this patch ?
Quoted 950 lines
Anyway, for 9p:
Reviewed-by Greg Kurz <[email protected]>Quoted 943 lines
Signed-off-by Markus Armbruster <[email protected]>--- scripts/coccinelle/return_directly.cocci | 5 +-- include/hw/pci/pci.h | 7 +-- target/avr/cpu.h | 4 +- hw/9pfs/9p-synth.c | 14 ++---- hw/char/sifive_uart.c | 4 +- hw/ppc/ppc4xx_sdram.c | 5 +-- hw/rdma/vmw/pvrdma_cmd.c | 57 +++++++++--------------- hw/virtio/vhost-user.c | 6 +-- migration/dirtyrate.c | 10 +---- migration/tls.c | 6 +-- replay/replay-time.c | 5 +-- semihosting/console.c | 4 +- softmmu/memory.c | 11 +---- softmmu/physmem.c | 9 +--- target/loongarch/cpu.c | 4 +- target/mips/tcg/dsp_helper.c | 15 ++----- target/riscv/debug.c | 6 +-- target/riscv/vector_helper.c | 28 +++--------- tests/bench/benchmark-crypto-akcipher.c | 6 +-- tests/qtest/erst-test.c | 5 +-- tests/qtest/hexloader-test.c | 6 +-- tests/qtest/pvpanic-pci-test.c | 6 +-- tests/qtest/pvpanic-test.c | 6 +-- tests/qtest/test-filter-mirror.c | 6 +-- tests/qtest/virtio-ccw-test.c | 6 +-- tests/tcg/multiarch/sha512.c | 9 +--- tools/virtiofsd/fuse_lowlevel.c | 24 +++------- 27 files changed, 70 insertions(+), 204 deletions(-)scripts/coccinelle/return_directly.cocci +2
-3@@ -11,9 +11,8 @@ identifier F; - T VAR; ... when != VAR -- VAR = -+ return - E; +- VAR = (E); - return VAR; ++ return E; ... when != VAR }include/hw/pci/pci.h +2
-5@@ -921,11 +921,8 @@ PCI_DMA_DEFINE_LDST(q_be, q_be, 64);static inline void *pci_dma_map (PCIDevice *dev,dma_addr_t addr,dma_addr_t *plen,DMADirection dir) { -void *buf; - - buf =dma_memory_map (pci_get_address_space (dev), addr, plen, dir, -MEMTXATTRS_UNSPECIFIED ); -return buf; +return dma_memory_map (pci_get_address_space (dev), addr, plen, dir, +MEMTXATTRS_UNSPECIFIED ); } static inline void pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len,target/avr/cpu.h +1
-3@@ -215,8 +215,7 @@ static inline int cpu_interrupts_enabled(CPUAVRState *env)static inline uint8_t cpu_get_sreg (CPUAVRState *env) { -uint8_t sreg; - sreg = (env->sregC) <<0 +return (env->sregC) <<0 | (env->sregZ) <<1 | (env->sregN) <<2 | (env->sregV) <<3 @@ -224,7 +223,6 @@ static inline uint8_t cpu_get_sreg(CPUAVRState *env) | (env->sregH) << 5 | (env->sregT) <<6 | (env->sregI) <<7 ; -return sreg; }static inline void cpu_set_sreg (CPUAVRState *env,uint8_t sreg)hw/9pfs/9p-synth.c +4
-10@@ -72,7 +72,6 @@ static V9fsSynthNode *v9fs_add_dir_node(V9fsSynthNode *parent, int mode,int qemu_v9fs_synth_mkdir (V9fsSynthNode *parent,int mode,const char *name,V9fsSynthNode **result) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {@@ -87,8 +86,7 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add the name */ @@ -98,15 +96,13 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,v9fs_add_dir_node (node, node->attr->mode,"." , node->attr, node->attr->inode); *result = node; - ret =0 ; -return ret; +return 0 ; }int qemu_v9fs_synth_add_file (V9fsSynthNode *parent,int mode,const char *name,v9fs_synth_read read,v9fs_synth_write write,void *arg) { -int ret;V9fsSynthNode *node, *tmp;if (!synth_fs) {@@ -122,8 +118,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,QEMU_LOCK_GUARD (&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) {if (!strcmp (tmp->name, name)) { - ret =EEXIST ; -return ret; +return EEXIST ; } }/* Add file type and remove write bits */ @@ -138,8 +133,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode, node->private = arg;pstrcpy (node->name,sizeof (node->name), name);QLIST_INSERT_HEAD_RCU (&parent->child, node, sibling); - ret =0 ; -return ret; +return 0 ; }static void synth_fill_statbuf (V9fsSynthNode *node,struct stat *stbuf)hw/char/sifive_uart.c +1
-3@@ -274,7 +274,6 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, {DeviceState *dev;SysBusDevice *s; -SiFiveUARTState *r; dev =qdev_new ("riscv.sifive.uart" ); s =SYS_BUS_DEVICE (dev);@@ -284,6 +283,5 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base, sysbus_mmio_get_region(s, 0));sysbus_connect_irq (s,0 , irq); - r =SIFIVE_UART (dev); -return r; +return SIFIVE_UART (dev); }hw/ppc/ppc4xx_sdram.c +1
-4@@ -520,13 +520,10 @@ static inline hwaddr sdram_ddr2_base(uint32_t bcr)static hwaddr sdram_ddr2_size (uint32_t bcr) { -hwaddr size;int sh; sh =1024 - ((bcr >>6 ) &0x3ff ); - size =8 * MiB * sh; - -return size; +return 8 * MiB * sh; }static uint32_t sdram_ddr2_dcr_read (void *opaque,int dcrn)hw/rdma/vmw/pvrdma_cmd.c +20
-37@@ -182,13 +182,10 @@ static int create_pd(PVRDMADev *dev, union pvrdma_cmd_req *req, {struct pvrdma_cmd_create_pd *cmd = &req->create_pd;struct pvrdma_cmd_create_pd_resp *resp = &rsp->create_pd_resp; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_alloc_pd (&dev->rdma_dev_res, &dev->backend_dev, - &resp->pd_handle, cmd->ctx_handle); - -return rc; +return rdma_rm_alloc_pd (&dev->rdma_dev_res, &dev->backend_dev, + &resp->pd_handle, cmd->ctx_handle); } static int destroy_pd(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -506,20 +503,17 @@ static int modify_qp(PVRDMADev *dev, union pvrdma_cmd_req *req, union pvrdma_cmd_resp *rsp) {struct pvrdma_cmd_modify_qp *cmd = &req->modify_qp; -int rc;/* No need to verify sgid_index since it is u8 */ - rc =rdma_rm_modify_qp (&dev->rdma_dev_res, &dev->backend_dev, - cmd->qp_handle, cmd->attr_mask, - cmd->attrs.ah_attr.grh.sgid_index, - (union ibv_gid *)&cmd->attrs.ah_attr.grh.dgid, - cmd->attrs.dest_qp_num, - (enum ibv_qp_state )cmd->attrs.qp_state, - cmd->attrs.qkey, cmd->attrs.rq_psn, - cmd->attrs.sq_psn); - -return rc; +return rdma_rm_modify_qp (&dev->rdma_dev_res, &dev->backend_dev, + cmd->qp_handle, cmd->attr_mask, + cmd->attrs.ah_attr.grh.sgid_index, + (union ibv_gid *)&cmd->attrs.ah_attr.grh.dgid, + cmd->attrs.dest_qp_num, + (enum ibv_qp_state )cmd->attrs.qp_state, + cmd->attrs.qkey, cmd->attrs.rq_psn, + cmd->attrs.sq_psn); } static int query_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -528,15 +522,14 @@ static int query_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,struct pvrdma_cmd_query_qp *cmd = &req->query_qp;struct pvrdma_cmd_query_qp_resp *resp = &rsp->query_qp_resp;struct ibv_qp_init_attr init_attr; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_query_qp (&dev->rdma_dev_res, &dev->backend_dev, cmd->qp_handle, - (struct ibv_qp_attr *)&resp->attrs, cmd->attr_mask, - &init_attr); - -return rc; +return rdma_rm_query_qp (&dev->rdma_dev_res, &dev->backend_dev, + cmd->qp_handle, + (struct ibv_qp_attr *)&resp->attrs, + cmd->attr_mask, + &init_attr); } static int destroy_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -562,34 +555,27 @@ static int create_bind(PVRDMADev *dev, union pvrdma_cmd_req *req, union pvrdma_cmd_resp *rsp) {struct pvrdma_cmd_create_bind *cmd = &req->create_bind; -int rc;union ibv_gid *gid = (union ibv_gid *)&cmd->new_gid;if (cmd->index >=MAX_PORT_GIDS ) {return -EINVAL ; } - rc =rdma_rm_add_gid (&dev->rdma_dev_res, &dev->backend_dev, - dev->backend_eth_device_name, gid, cmd->index); - -return rc; +return rdma_rm_add_gid (&dev->rdma_dev_res, &dev->backend_dev, + dev->backend_eth_device_name, gid, cmd->index); }static int destroy_bind (PVRDMADev *dev,union pvrdma_cmd_req *req,union pvrdma_cmd_resp *rsp) { -int rc; -struct pvrdma_cmd_destroy_bind *cmd = &req->destroy_bind;if (cmd->index >=MAX_PORT_GIDS ) {return -EINVAL ; } - rc =rdma_rm_del_gid (&dev->rdma_dev_res, &dev->backend_dev, - dev->backend_eth_device_name, cmd->index); - -return rc; +return rdma_rm_del_gid (&dev->rdma_dev_res, &dev->backend_dev, + dev->backend_eth_device_name, cmd->index); } static int create_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,@@ -597,12 +583,9 @@ static int create_uc(PVRDMADev *dev, union pvrdma_cmd_req *req, {struct pvrdma_cmd_create_uc *cmd = &req->create_uc;struct pvrdma_cmd_create_uc_resp *resp = &rsp->create_uc_resp; -int rc;memset (resp,0 ,sizeof (*resp)); - rc =rdma_rm_alloc_uc (&dev->rdma_dev_res, cmd->pfn, &resp->ctx_handle); - -return rc; +return rdma_rm_alloc_uc (&dev->rdma_dev_res, cmd->pfn, &resp->ctx_handle); } static int destroy_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,hw/virtio/vhost-user.c +1
-5@@ -2532,11 +2532,7 @@ vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id)static bool vhost_user_mem_section_filter (struct vhost_dev *dev,MemoryRegionSection *section) { -bool result; - - result =memory_region_get_fd (section->mr) >=0 ; - -return result; +return memory_region_get_fd (section->mr) >=0 ; } static int vhost_user_get_inflight_fd(struct vhost_dev *dev,migration/dirtyrate.c +2
-8@@ -111,7 +111,6 @@ static void global_dirty_log_sync(unsigned int flag, bool one_shot)static DirtyPageRecord *vcpu_dirty_stat_alloc (VcpuStat *stat) {CPUState *cpu; -DirtyPageRecord *records;int nvcpu =0 ;CPU_FOREACH (cpu) {@@ -121,9 +120,7 @@ static DirtyPageRecord *vcpu_dirty_stat_alloc(VcpuStat *stat) stat->nvcpu = nvcpu; stat->rates =g_new0 (DirtyRateVcpu, nvcpu); - records =g_new0 (DirtyPageRecord, nvcpu); - -return records; +return g_new0 (DirtyPageRecord, nvcpu); } static void vcpu_dirty_stat_collect(VcpuStat *stat,@@ -473,7 +470,6 @@ find_block_matched(RAMBlock *block, int count, struct RamblockDirtyInfo *infos) {int i; -struct RamblockDirtyInfo *matched;for (i =0 ; i < count; i++) {if (!strcmp (infos[i].idstr,qemu_ram_get_idstr (block))) {@@ -492,9 +488,7 @@ find_block_matched(RAMBlock *block, int count,return NULL ; } - matched = &infos[i]; - -return matched; +return &infos[i]; } static bool compare_page_hash_info(struct RamblockDirtyInfo *info,migration/tls.c +1
-5@@ -126,7 +126,6 @@ QIOChannelTLS *migration_tls_client_create(MigrationState *s, Error **errp) {QCryptoTLSCreds *creds; -QIOChannelTLS *tioc; creds =migration_tls_get_creds ( s,QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT , errp);@@ -138,10 +137,7 @@ QIOChannelTLS *migration_tls_client_create(MigrationState *s, hostname = s->parameters.tls_hostname; } - tioc =qio_channel_tls_new_client ( - ioc, creds, hostname, errp); - -return tioc; +return qio_channel_tls_new_client (ioc, creds, hostname, errp); } void migration_tls_channel_connect(MigrationState *s,replay/replay-time.c +1
-4@@ -48,7 +48,6 @@ void replay_read_next_clock(ReplayClockKind kind)/*! Reads next clock event from the input. */ int64_t replay_read_clock (ReplayClockKind kind,int64_t raw_icount) { -int64_t ret;g_assert (replay_file &&replay_mutex_locked ());replay_advance_current_icount (raw_icount);@@ -56,7 +55,5 @@ int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount)if (replay_next_event_is (EVENT_CLOCK + kind)) {replay_read_next_clock (kind); } - ret = replay_state.cached_clock[kind]; - -return ret; +return replay_state.cached_clock[kind]; }semihosting/console.c +1
-3@@ -43,10 +43,8 @@ static SemihostingConsole console;static int console_can_read (void *opaque) {SemihostingConsole *c = opaque; -int ret;g_assert (qemu_mutex_iothread_locked ()); - ret = (int )fifo8_num_free (&c->fifo); -return ret; +return (int )fifo8_num_free (&c->fifo); }static void console_wake_up (gpointer data,gpointer user_data)softmmu/memory.c +2
-9@@ -2372,20 +2372,15 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,int memory_region_get_fd (MemoryRegion *mr) { -int fd; -RCU_READ_LOCK_GUARD ();while (mr->alias) { mr = mr->alias; } - fd = mr->ram_block->fd; - -return fd; +return mr->ram_block->fd; }void *memory_region_get_ram_ptr (MemoryRegion *mr) { -void *ptr;uint64_t offset =0 ;RCU_READ_LOCK_GUARD ();@@ -2394,9 +2389,7 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr) mr = mr->alias; }assert (mr->ram_block); - ptr =qemu_map_ram_ptr (mr->ram_block, offset); - -return ptr; +return qemu_map_ram_ptr (mr->ram_block, offset); }MemoryRegion *memory_region_from_host (void *ptr,ram_addr_t *offset)softmmu/physmem.c +2
-7@@ -3236,7 +3236,6 @@ void *address_space_map(AddressSpace *as,hwaddr len = *plen;hwaddr l, xlat;MemoryRegion *mr; -void *ptr;FlatView *fv;if (len ==0 ) {@@ -3275,9 +3274,7 @@ void *address_space_map(AddressSpace *as, *plen =flatview_extend_translation (fv, addr, len, mr, xlat, l, is_write, attrs);fuzz_dma_read_cb (addr, *plen, mr); - ptr =qemu_ram_ptr_length (mr->ram_block, xlat, plen, true); - -return ptr; +return qemu_ram_ptr_length (mr->ram_block, xlat, plen, true); }/* Unmaps a memory region previously mapped by address_space_map(). @@ -3545,15 +3542,13 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) {MemoryRegion *mr;hwaddr l =1 ; -bool res;RCU_READ_LOCK_GUARD (); mr =address_space_translate (&address_space_memory, phys_addr, &phys_addr, &l, false,MEMTXATTRS_UNSPECIFIED ); - res = !(memory_region_is_ram (mr) ||memory_region_is_romd (mr)); -return res; +return !(memory_region_is_ram (mr) ||memory_region_is_romd (mr)); }int qemu_ram_foreach_block (RAMBlockIterFunc func,void *opaque)target/loongarch/cpu.c +1
-3@@ -128,13 +128,11 @@ static inline bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env) {uint32_t pending;uint32_t status; -bool r; pending =FIELD_EX64 (env->CSR_ESTAT,CSR_ESTAT ,IS ); status =FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,LIE ); - r = (pending & status) !=0 ; -return r; +return (pending & status) !=0 ; }static void loongarch_cpu_do_interrupt (CPUState *cs)target/mips/tcg/dsp_helper.c +3
-12@@ -3281,15 +3281,12 @@ target_ulong helper_dextr_l(target_ulong ac, target_ulong shift, CPUMIPSState *env) {uint64_t temp[3 ]; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env); - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); } target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,@@ -3297,7 +3294,6 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift, {uint64_t temp[3 ];uint32_t temp128; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env);@@ -3317,9 +3313,7 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,set_DSPControl_overflow_flag (1 ,23 , env); } - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); } target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift,@@ -3327,7 +3321,6 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift, {uint64_t temp[3 ];uint32_t temp128; -target_ulong ret; shift = shift &0x3F ;mipsdsp_rndrashift_acc (temp, ac, shift, env);@@ -3354,9 +3347,7 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift, set_DSPControl_overflow_flag(1, 23, env); } - ret = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); - -return ret; +return (temp[1 ] <<63 ) | (temp[0 ] >>1 ); }#endif target/riscv/debug.c +2
-4@@ -243,15 +243,13 @@ static void do_trigger_action(CPURISCVState *env, target_ulong trigger_index)static uint32_t type2_breakpoint_size (CPURISCVState *env,target_ulong ctrl) { -uint32_t size, sizelo, sizehi =0 ; +uint32_t sizelo, sizehi =0 ;if (riscv_cpu_mxl (env) ==MXL_RV64 ) { sizehi =extract32 (ctrl,21 ,2 ); } sizelo =extract32 (ctrl,16 ,2 ); - size = (sizehi <<2 ) | sizelo; - -return size; +return (sizehi <<2 ) | sizelo; }static inline bool type2_breakpoint_enabled (target_ulong ctrl)target/riscv/vector_helper.c +7
-21@@ -2791,31 +2791,25 @@ static inline uint16_t vssrl16(CPURISCVState *env, int vxrm, uint16_t a, uint16_t b) {uint8_t round, shift = b &0xf ; -uint16_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline uint32_t vssrl32 (CPURISCVState *env,int vxrm,uint32_t a,uint32_t b) {uint8_t round, shift = b &0x1f ; -uint32_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline uint64_t vssrl64 (CPURISCVState *env,int vxrm,uint64_t a,uint64_t b) {uint8_t round, shift = b &0x3f ; -uint64_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; } RVVCALL(OPIVV2_RM, vssrl_vv_b, OP_UUU_B, H1, H1, H1, vssrl8)RVVCALL (OPIVV2_RM , vssrl_vv_h,OP_UUU_H ,H2 ,H2 ,H2 , vssrl16)@@ -2839,41 +2833,33 @@ static inline int8_t vssra8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) {uint8_t round, shift = b &0x7 ; -int8_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int16_t vssra16 (CPURISCVState *env,int vxrm,int16_t a,int16_t b) {uint8_t round, shift = b &0xf ; -int16_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int32_t vssra32 (CPURISCVState *env,int vxrm,int32_t a,int32_t b) {uint8_t round, shift = b &0x1f ; -int32_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }static inline int64_t vssra64 (CPURISCVState *env,int vxrm,int64_t a,int64_t b) {uint8_t round, shift = b &0x3f ; -int64_t res; round =get_round (vxrm, a, shift); - res = (a >> shift) + round; -return res; +return (a >> shift) + round; }RVVCALL (OPIVV2_RM , vssra_vv_b,OP_SSS_B ,H1 ,H1 ,H1 , vssra8)tests/bench/benchmark-crypto-akcipher.c +2
-4@@ -24,14 +24,12 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, QCryptoHashAlgorithm hash) {QCryptoAkCipherOptions opt; -QCryptoAkCipher *rsa; opt.alg =QCRYPTO_AKCIPHER_ALG_RSA ; opt.u.rsa.padding_alg = padding; opt.u.rsa.hash_alg = hash; - rsa =qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , - priv_key, keylen, &error_abort); -return rsa; +return qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , + priv_key, keylen, &error_abort); } static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,tests/qtest/erst-test.c +1
-4@@ -154,10 +154,7 @@ static void test_acpi_erst_basic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/acpi-erst/basic" , test_acpi_erst_basic); - ret =g_test_run (); -return ret; +return g_test_run (); }tests/qtest/hexloader-test.c +1
-5@@ -34,12 +34,8 @@ static void hex_loader_test(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/tmp/hex_loader" , hex_loader_test); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/pvpanic-pci-test.c +1
-5@@ -86,13 +86,9 @@ static void test_panic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic-pci/panic" , test_panic);qtest_add_func ("/pvpanic-pci/panic-nopause" , test_panic_nopause); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/pvpanic-test.c +1
-5@@ -59,13 +59,9 @@ static void test_panic(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/pvpanic/panic" , test_panic);qtest_add_func ("/pvpanic/panic-nopause" , test_panic_nopause); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/test-filter-mirror.c +1
-5@@ -76,12 +76,8 @@ static void test_mirror(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/netfilter/mirror" , test_mirror); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/qtest/virtio-ccw-test.c +1
-5@@ -95,8 +95,6 @@ static void virtio_scsi_hotplug(void)int main (int argc,char **argv) { -int ret; -g_test_init (&argc, &argv,NULL );qtest_add_func ("/virtio/balloon/nop" , virtio_balloon_nop);qtest_add_func ("/virtio/console/nop" , virtconsole_nop);@@ -109,7 +107,5 @@ int main(int argc, char **argv)qtest_add_func ("/virtio/scsi/nop" , virtio_scsi_nop);qtest_add_func ("/virtio/scsi/hotplug" , virtio_scsi_hotplug); - ret =g_test_run (); - -return ret; +return g_test_run (); }tests/tcg/multiarch/sha512.c +2
-7@@ -855,8 +855,6 @@ plan_tests(unsigned int tests)static int exit_status_ (void ) { -int r; -/* If there's no plan, just return the number of failures */ if (no_plan || !have_plan) {return failures;@@ -865,15 +863,12 @@ exit_status_(void)/* Ran too many tests? Return the number of tests that were run that shouldn't have been */ if (e_tests < test_count) { - r = test_count - e_tests; -return r; +return test_count - e_tests; }/* Return the number of tests that failed + the number of tests that weren't run */ - r = failures + e_tests - test_count; - -return r; +return failures + e_tests - test_count; }int tools/virtiofsd/fuse_lowlevel.c +6
-18@@ -216,7 +216,6 @@ static int send_reply(fuse_req_t req, int error, const void *arg,int fuse_reply_iov (fuse_req_t req,const struct iovec *iov,int count) { -int res; g_autofree struct iovec *padded_iov = NULL; padded_iov = g_try_new(struct iovec, count + 1);@@ -227,9 +226,7 @@ int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)memcpy (padded_iov +1 , iov, count *sizeof (struct iovec )); count++; - res =send_reply_iov (req,0 , padded_iov, count); - -return res; +return send_reply_iov (req,0 , padded_iov, count); }@@ -589,7 +586,6 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov, g_autofree struct fuse_ioctl_iovec *out_fiov = NULL;struct iovec iov[4 ];size_t count =1 ; -int res;memset (&arg,0 ,sizeof (arg)); arg.flags |=FUSE_IOCTL_RETRY ;@@ -601,15 +597,13 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,/* Can't handle non-compat 64bit ioctls on 32bit */ if (sizeof (void *) ==4 && req->ioctl_64bit) { - res =fuse_reply_err (req,EINVAL ); -return res; +return fuse_reply_err (req,EINVAL ); }if (in_count) { in_fiov =fuse_ioctl_iovec_copy (in_iov, in_count);if (!in_fiov) { - res =fuse_reply_err (req,ENOMEM ); -return res; +return fuse_reply_err (req,ENOMEM ); } iov[count].iov_base = (void *)in_fiov;@@ -619,8 +613,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,if (out_count) { out_fiov =fuse_ioctl_iovec_copy (out_iov, out_count);if (!out_fiov) { - res =fuse_reply_err (req,ENOMEM ); -return res; +return fuse_reply_err (req,ENOMEM ); } iov[count].iov_base = (void *)out_fiov;@@ -628,9 +621,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov, count++; } - res =send_reply_iov (req,0 , iov, count); - -return res; +return send_reply_iov (req,0 , iov, count); }int fuse_reply_ioctl (fuse_req_t req,int result,const void *buf,size_t size)@@ -659,7 +650,6 @@ int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov, { g_autofree struct iovec *padded_iov = NULL;struct fuse_ioctl_out arg; -int res; padded_iov = g_try_new(struct iovec, count + 2);if (padded_iov ==NULL ) {@@ -673,9 +663,7 @@ int fuse_reply_ioctl_iov(fuse_req_t req, int result, const struct iovec *iov,memcpy (&padded_iov[2 ], iov, count *sizeof (struct iovec )); - res =send_reply_iov (req,0 , padded_iov, count +2 ); - -return res; +return send_reply_iov (req,0 , padded_iov, count +2 ); }int fuse_reply_poll (fuse_req_t req,unsigned revents)
Quoted 33 lines · Greg Kurz
Quoted 30 lines · On Thu, 24 Nov 2022 16:15:11 +0100 Greg Kurz <[email protected]> wrote:
Quoted 9 lines · On Tue, 22 Nov 2022 14:49:16 +0100 Markus Armbruster <[email protected]> wrote:
Tweak the semantic patch to drop redundant parenthesis around the return expression.
Coccinelle drops a comment in
hw/rdma/vmw/pvrdma_cmd.c; restored manually.Coccinelle messes up
vmdk_co_create(), not sure why. Change dropped, will be done manually in the next commit.Quoted 9 lines
Line breaks in
target/avr/cpu.handhw/rdma/vmw/pvrdma_cmd.ctidied up manually.Whitespace in
tools/virtiofsd/fuse_lowlevel.ctidied up manually.checkpatch.pl complains "return of an errno should typically be -ve" two times for
hw/9pfs/9p-synth.c. Preexisting, the patch merely makes it visible to checkpatch.pl.Hi Markus,
Yeah these positive errno values have been sitting there since the beginning. It was dead code until I hijacked the synth backend to implement qtest for 9p. I didn't care much about the return value of the two culprits at the time since both are passed to assert(!ret) right away. For this reason, changing the sign should be easy :-)
Quoted 7 lines
Quoted 4 lines
I see that checkpatch.pl considers this as an error. I'll post a fix. I guess you'll need to rebase on this fix for your patches to pass CI.
Or maybe I can fix the issues detected by coccinelle as well and you can just drop the 9p bits from this patch ?
Up to you!
Quoted 3 lines
Quoted 3 lines
Anyway, for 9p:
Reviewed-by Greg Kurz <[email protected]>
Thanks!
PATCH v2 2/2 block/vmdk: Simplify vmdk_co_create() to return directly
In reply to Markus Armbruster--- block/vmdk.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
block/vmdk.c +11 -17
@@ -2821,7 +2821,6 @@ static BlockBackend *vmdk_co_create_cb(int64_t size, int idx, static int coroutine_fn vmdk_co_create(BlockdevCreateOptions *create_options,Error **errp) { -int ret;BlockdevCreateOptionsVmdk *opts; opts = &create_options->u.vmdk;
@@ -2829,24 +2828,19 @@ static int coroutine_fn vmdk_co_create(BlockdevCreateOptions *create_options,/* Validate options */ if (!QEMU_IS_ALIGNED (opts->size,BDRV_SECTOR_SIZE )) {error_setg (errp,"Image size must be a multiple of 512 bytes" ); - ret = -EINVAL ; - goto out; +return -EINVAL ; } - ret =vmdk_co_do_create (opts->size, - opts->subformat, - opts->adapter_type, - opts->backing_file, - opts->hwversion, - opts->toolsversion, - false, - opts->zeroed_grain, - vmdk_co_create_cb, - opts, errp); -return ret; - -out: -return ret; +return vmdk_co_do_create (opts->size, + opts->subformat, + opts->adapter_type, + opts->backing_file, + opts->hwversion, + opts->toolsversion, + false, + opts->zeroed_grain, + vmdk_co_create_cb, + opts, errp); }static void vmdk_close (BlockDriverState *bs)
Signature · 1 line
2.37.3
Re: [PATCH v2 2/2] block/vmdk: Simplify vmdk_co_create() to return directly
Quoted 10 lines · Markus Armbruster
Cc Fam Zheng <[email protected]>Cc Kevin Wolf <[email protected]>Cc Hanna Reitz <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- block/vmdk.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
thanks
-- PMM
Re: [PATCH v2 2/2] block/vmdk: Simplify vmdk_co_create() to return directly
In reply to Markus ArmbrusterQuoted 8 lines · Markus Armbruster
Cc Fam Zheng <[email protected]>Cc Kevin Wolf <[email protected]>Cc Hanna Reitz <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- block/vmdk.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
[PATCH 3/2] ppc4xx_sdram: Simplify sdram_ddr_size() to return
In reply to Markus Armbruster--- hw/ppc/ppc4xx_sdram.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
hw/ppc/ppc4xx_sdram.c +3 -7
@@ -192,17 +192,13 @@ static inline hwaddr sdram_ddr_base(uint32_t bcr)static hwaddr sdram_ddr_size (uint32_t bcr) { -hwaddr size; -int sh; +int sh = (bcr >>17 ) &0x7 ; - sh = (bcr >>17 ) &0x7 ;if (sh ==7 ) { - size =-1 ; - }else { - size = (4 * MiB) << sh; +return -1 ; } -return size; +return (4 * MiB) << sh; }static uint32_t sdram_ddr_dcr_read (void *opaque,int dcrn)
Signature · 1 line
2.37.3
BALATON Zoltan
Reviewed-byRe: [PATCH 3/2] ppc4xx_sdram: Simplify sdram_ddr_size() to return
Quoted 2 lines · Markus Armbruster
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
I thought you could include the hunk modifying sdram_ddr2_size in this patch too and make it a separate clean up to reduce the size of the Coccinelle patch making that easier to review but it's OK either way. Thanks for doing this clean up.
Regards,
BALATON Zoltan
Quoted 30 lines
---
hw/ppc/ppc4xx_sdram.c| 10 +++-------1 file changed, 3 insertions(+), 7 deletions(-)hw/ppc/ppc4xx_sdram.c +3
-7@@ -192,17 +192,13 @@ static inline hwaddr sdram_ddr_base(uint32_t bcr)static hwaddr sdram_ddr_size (uint32_t bcr) { -hwaddr size; -int sh; +int sh = (bcr >>17 ) &0x7 ; - sh = (bcr >>17 ) &0x7 ;if (sh ==7 ) { - size =-1 ; - }else { - size = (4 * MiB) << sh; +return -1 ; } -return size; +return (4 * MiB) << sh; }static uint32_t sdram_ddr_dcr_read (void *opaque,int dcrn)
Re: [PATCH 3/2] ppc4xx_sdram: Simplify sdram_ddr_size() to return
Quoted 8 lines · BALATON Zoltan
Quoted 2 lines · Markus Armbruster
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Markus Armbruster <[email protected]>Reviewed-by BALATON Zoltan <[email protected]>I thought you could include the hunk modifying
sdram_ddr2_sizein this patch too and make it a separate clean up to reduce the size of the Coccinelle patch making that easier to review but it's OK either way. Thanks for doing this clean up.
Yes, I could do that, but since I got R-bys already, I opted for minimizing change.
Thanks!
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH 3/2] ppc4xx_sdram: Simplify sdram_ddr_size() to return
In reply to Markus ArmbrusterQuoted 5 lines · Markus Armbruster
Suggested-by BALATON Zoltan <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/ppc/ppc4xx_sdram.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)