usb: Change *_exitfn return type from void to int
PATCH 1/1 usb: Change *_exitfn return type from void to int
The *_exitfn functions cannot fail and should not be returning int.
Suggested as a Bite-sized task
--- hw/usb/ccid-card-emulated.c | 4 ++-- hw/usb/ccid-card-passthru.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
hw/usb/ccid-card-emulated.c +2 -2
@@ -547,7 +547,7 @@ static int emulated_initfn(CCIDCardState *base)return 0 ; } -static int emulated_exitfn (CCIDCardState *base) +static void emulated_exitfn (CCIDCardState *base) {EmulatedState *card =EMULATED_CCID_CARD (base);VEvent *vevent =vevent_new (VEVENT_LAST ,NULL ,NULL );
@@ -564,7 +564,7 @@ static int emulated_exitfn(CCIDCardState *base)qemu_mutex_destroy (&card->handle_apdu_mutex);qemu_mutex_destroy (&card->vreader_mutex);qemu_mutex_destroy (&card->event_list_mutex); -return 0 ; +return ; }static Property emulated_card_properties[] = {
hw/usb/ccid-card-passthru.c +2 -2
@@ -364,9 +364,9 @@ static int passthru_initfn(CCIDCardState *base)return 0 ; } -static int passthru_exitfn (CCIDCardState *base) +static void passthru_exitfn (CCIDCardState *base) { -return 0 ; +return ; }static VMStateDescription passthru_vmstate = {
Signature · 1 line
1.9.1
Quoted 1 line · Akanksha Srivastava
Subject: [Qemu-devel] [PATCH] usb: Change
*_exitfnreturn type from void to int
This should read "from int to void", I guess.
Quoted 8 lines
The
*_exitfnfunctions cannot fail and should not be returning int.
Suggested as a Bite-sized taskSigned-off-by Akanksha Srivastava <[email protected]>--- hw/usb/ccid-card-emulated.c | 4 ++-- hw/usb/ccid-card-passthru.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
[...]
hw/usb/ccid-card-passthru.c static int passthru_initfn(CCIDCardState *base) · line 370
Quoted 6 lines
hw/usb/ccid-card-passthru.c +2
-2-static int passthru_exitfn (CCIDCardState *base) +static void passthru_exitfn (CCIDCardState *base) { -return 0 ; +return ; }
Have you compile-tested this change? I think you'll have to adjust the definition of exitfn in CCIDCardClass, and ccid_card_exitfn (in hw/usb/dev-smartcard-reader.c) as well.
Regards,
Jonathan Neuschäfer
Quoted 23 lines · Akanksha Srivastava
The
*_exitfnfunctions cannot fail and should not be returning int.
Suggested as a Bite-sized taskSigned-off-by Akanksha Srivastava <[email protected]>--- hw/usb/ccid-card-emulated.c | 4 ++-- hw/usb/ccid-card-passthru.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)hw/usb/ccid-card-emulated.c +1
-1@@ -547,7 +547,7 @@ static int emulated_initfn(CCIDCardState *base)return 0 ; } -static int emulated_exitfn (CCIDCardState *base) +static void emulated_exitfn (CCIDCardState *base) {EmulatedState *card =EMULATED_CCID_CARD (base);VEvent *vevent =vevent_new (VEVENT_LAST ,NULL ,NULL );
hw/usb/ccid-card-emulated.c static int emulated_exitfn(CCIDCardState *base) · line 568
Quoted 6 lines
hw/usb/ccid-card-emulated.c +1
-1@@ -564,7 +564,7 @@ static int emulated_exitfn(CCIDCardState *base)qemu_mutex_destroy (&card->handle_apdu_mutex);qemu_mutex_destroy (&card->vreader_mutex);qemu_mutex_destroy (&card->event_list_mutex); -return 0 ; +return ; }
Ending a function that returns void with 'return' is redundant; just drop the return statement altogether if it is the last thing that can be reached.
Quoted 7 lines
hw/usb/ccid-card-emulated.c +0
-0static Property emulated_card_properties[] = {hw/usb/ccid-card-passthru.c +0
-0
hw/usb/ccid-card-passthru.c static int passthru_initfn(CCIDCardState *base) · line 370
Quoted 9 lines
hw/usb/ccid-card-passthru.c +2
-2@@ -364,9 +364,9 @@ static int passthru_initfn(CCIDCardState *base)return 0 ; } -static int passthru_exitfn (CCIDCardState *base) +static void passthru_exitfn (CCIDCardState *base) { -return 0 ; +return ; }
And again. Since the callback does nothing, do you even need it to exist, or can you do further cleanups that allow the callback to be optional if it would otherwise be a no-op?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org