Remove superfluous return statements
cover Remove superfluous return statements
Some functions in QEMU have a "return;" statement at the very end of a function with "void" return type, i.e. the return statement is superfluous. This patch series removes some of them.
Thomas Huth (4):
hw/ide: Remove superfluous return statements hw/acpi: Remove superfluous return statement hw/s390x: Remove superfluous return statements hw/core/qdev: Remove superfluous return statement
hw/acpi/memory_hotplug.c | 1 - hw/core/qdev.c | 1 - hw/ide/atapi.c | 1 - hw/ide/macio.c | 2 -- hw/s390x/css.c | 1 - hw/s390x/event-facility.c | 21 ++++++--------------- hw/s390x/s390-pci-bus.c | 4 ---- 7 files changed, 6 insertions(+), 25 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/4 hw/ide: Remove superfluous return statements
The "return;" statements at the end of functions do not make much sense, so let's remove them.
--- hw/ide/atapi.c | 1 - hw/ide/macio.c | 2 -- 2 files changed, 3 deletions(-)
hw/ide/atapi.c +0 -1
@@ -737,7 +737,6 @@ static void cmd_inquiry(IDEState *s, uint8_t *buf) out: buf[size_idx] = idx - preamble_len;ide_atapi_cmd_reply (s, idx, max_len); -return ; }static void cmd_get_configuration (IDEState *s,uint8_t *buf)
hw/ide/macio.c +0 -2
@@ -288,8 +288,6 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) done:block_acct_done (blk_get_stats (s->blk), &s->acct); io->dma_end (opaque); - -return ; }static void pmac_ide_transfer_cb (void *opaque,int ret)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 1/4] hw/ide: Remove superfluous return statements
Quoted 29 lines · Thomas Huth
The "return;" statements at the end of functions do not make much sense, so let's remove them.
--- hw/ide/atapi.c | 1 - hw/ide/macio.c | 2 -- 2 files changed, 3 deletions(-)hw/ide/atapi.c +0
-1@@ -737,7 +737,6 @@ static void cmd_inquiry(IDEState *s, uint8_t *buf) out: buf[size_idx] = idx - preamble_len;ide_atapi_cmd_reply (s, idx, max_len); -return ; }static void cmd_get_configuration (IDEState *s,uint8_t *buf)hw/ide/macio.c +0
-0
hw/ide/macio.c static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) · line 293
Quoted 8 lines
hw/ide/macio.c +0
-2@@ -288,8 +288,6 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) done:block_acct_done (blk_get_stats (s->blk), &s->acct); io->dma_end (opaque); - -return ; }static void pmac_ide_transfer_cb (void *opaque,int ret)
Fair enough.
PATCH 2/4 hw/acpi: Remove superfluous return statement
In reply to Thomas HuthThe "return;" statement at the end of acpi_memory_plug_cb() does not make much sense, so let's remove it.
--- hw/acpi/memory_hotplug.c | 1 - 1 file changed, 1 deletion(-)
hw/acpi/memory_hotplug.c +0 -1
@@ -244,7 +244,6 @@ void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,/* do ACPI magic */ acpi_send_gpe_event (ar, irq,ACPI_MEMORY_HOTPLUG_STATUS ); } -return ; } void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
Signature · 1 line
1.8.3.1
PATCH 3/4 hw/s390x: Remove superfluous return statements
In reply to Thomas HuthThe "return;" statements at the end of functions do not make much sense, so let's remove them.
--- hw/s390x/css.c | 1 - hw/s390x/event-facility.c | 21 ++++++--------------- hw/s390x/s390-pci-bus.c | 4 ---- 3 files changed, 6 insertions(+), 20 deletions(-)
hw/s390x/css.c +0 -1
@@ -1424,7 +1424,6 @@ void subch_device_save(SubchDev *s, QEMUFile *f) }qemu_put_byte (f, s->ccw_fmt_1);qemu_put_byte (f, s->ccw_no_data_cnt); -return ; }int subch_device_load (SubchDev *s,QEMUFile *f)
hw/s390x/event-facility.c +6 -15
@@ -158,11 +158,11 @@ static void write_event_data(SCLPEventFacility *ef, SCCB *sccb) {if (sccb->h.function_code !=SCLP_FC_NORMAL_WRITE ) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_FUNCTION ); - goto out; +return ; }if (be16_to_cpu (sccb->h.length) <8 ) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_INSUFFICIENT_SCCB_LENGTH ); - goto out; +return ; }/* first do a sanity check of the write events */ sccb->h.response_code =cpu_to_be16 (write_event_length_check (sccb));
@@ -172,9 +172,6 @@ static void write_event_data(SCLPEventFacility *ef, SCCB *sccb) sccb->h.response_code =cpu_to_be16 (handle_sccb_write_events (ef, sccb)); } - -out: -return ; } static uint16_t handle_sccb_read_events(SCLPEventFacility *ef, SCCB *sccb,
@@ -227,7 +224,7 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb)if (be16_to_cpu (sccb->h.length) !=SCCB_SIZE ) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_INSUFFICIENT_SCCB_LENGTH ); - goto out; +return ; } sclp_cp_receive_mask = ef->receive_mask;
@@ -243,18 +240,15 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb) (sclp_active_selection_mask & ~sclp_cp_receive_mask)) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SELECTION_MASK ); - goto out; +return ; }break ;default : sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_FUNCTION ); - goto out; +return ; } sccb->h.response_code =cpu_to_be16 (handle_sccb_read_events (ef, sccb, sclp_active_selection_mask)); - -out: -return ; }static void write_event_mask (SCLPEventFacility *ef,SCCB *sccb)
@@ -265,7 +259,7 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb)does. Architecture allows for masks of variable size, though */ if (be16_to_cpu (we_mask->mask_length) !=4 ) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_MASK_LENGTH ); - goto out; +return ; }/* keep track of the guest's capability masks */
@@ -276,9 +270,6 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb) we_mask->receive_mask =cpu_to_be32 (get_host_receive_mask (ef)); sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_COMPLETION ); - -out: -return ; }/* qemu object creation and initialization functions */
hw/s390x/s390-pci-bus.c +0 -4
@@ -123,7 +123,6 @@ void s390_pci_sclp_configure(int configure, SCCB *sccb) } psccb->header.response_code =cpu_to_be16 (rc); -return ; }static uint32_t s390_pci_get_pfid (PCIDevice *pdev)
@@ -435,8 +434,6 @@ static void s390_msi_ctrl_write(void *opaque, hwaddr addr, uint64_t data, io_int_word = (pbdev->isc <<27 ) |IO_INT_WORD_AI ;s390_io_interrupt (0 ,0 ,0 , io_int_word); } - -return ; }static uint64_t s390_msi_ctrl_read (void *opaque,hwaddr addr,unsigned size)
@@ -539,7 +536,6 @@ static void s390_pcihost_hot_plug(HotplugHandler *hotplug_dev,s390_pci_generate_plug_event (HP_EVENT_TO_CONFIGURED , pbdev->fh, pbdev->fid); } -return ; } static void s390_pcihost_hot_unplug(HotplugHandler *hotplug_dev,
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 3/4] hw/s390x: Remove superfluous return statements
Quoted 8 lines · On Tue, 10 Nov 2015 21:16:10 +0100 Thomas Huth <[email protected]> wrote:
The "return;" statements at the end of functions do not make much sense, so let's remove them.
Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Thomas Huth <[email protected]>
Quoted 6 lines
--- hw/s390x/css.c | 1 - hw/s390x/event-facility.c | 21 ++++++--------------- hw/s390x/s390-pci-bus.c | 4 ---- 3 files changed, 6 insertions(+), 20 deletions(-)
Ack for the css and pci parts.
The sclp parts, however, switch from "one point of exit" to "immediate exit", and I'm not sure I like that; not sure enough anyway to apply this patch.
Re: [Qemu-devel] [PATCH 3/4] hw/s390x: Remove superfluous return statements
Quoted 18 lines · Cornelia Huck
Quoted 8 lines · On Tue, 10 Nov 2015 21:16:10 +0100 Thomas Huth <[email protected]> wrote:
The "return;" statements at the end of functions do not make much sense, so let's remove them.
Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Thomas Huth <[email protected]>Quoted 6 lines
--- hw/s390x/css.c | 1 - hw/s390x/event-facility.c | 21 ++++++--------------- hw/s390x/s390-pci-bus.c | 4 ---- 3 files changed, 6 insertions(+), 20 deletions(-)
Quoted 5 lines
Ack for the css and pci parts.
The sclp parts, however, switch from "one point of exit" to "immediate exit", and I'm not sure I like that; not sure enough anyway to apply this patch.
Ah, right, I remember, you're prefering gotos ... well, no, I won't start a discussion about that here again ;-) ... so feel free to remove these hunks or simply ignore the patch completely.
Cheers,
Thomas
PATCH 4/4 hw/core/qdev: Remove superfluous return statement
In reply to Thomas HuthThe "return;" statement at the end of device_set_realized() does not make much sense, so let's remove it.
--- hw/core/qdev.c | 1 - 1 file changed, 1 deletion(-)
hw/core/qdev.c +0 -1
@@ -1129,7 +1129,6 @@ post_realize_fail: fail:error_propagate (errp, local_err); -return ; }static bool device_get_hotpluggable (Object *obj,Error **errp)
Signature · 1 line
1.8.3.1
Quoted 10 lines · Thomas Huth
Some functions in QEMU have a "return;" statement at the very end of a function with "void" return type, i.e. the return statement is superfluous. This patch series removes some of them.
Thomas Huth (4):
hw/ide: Remove superfluous return statements hw/acpi: Remove superfluous return statement hw/s390x: Remove superfluous return statements hw/core/qdev: Remove superfluous return statement
(Finally!) applied to -trivial, after removing changes to hw/s390x/event-facility.c from hw/s390x patch as discussed before.
Thank you, and please excuse me it took so long :)
/mjt