qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH] usb: Change *_exitfn return type from void to int
@ 2016-09-30 17:51 Akanksha Srivastava
  2016-09-30 18:06 ` [Qemu-trivial] [Qemu-devel] " Jonathan Neuschäfer
  2016-09-30 18:46 ` Eric Blake
  0 siblings, 2 replies; 3+ messages in thread
From: Akanksha Srivastava @ 2016-09-30 17:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, kraxel, Akanksha Srivastava

The *_exitfn functions cannot fail and should not be
returning int.
Suggested as a Bite-sized task
Signed-off-by: Akanksha Srivastava <akanksha.dlf@gmail.com>
---
 hw/usb/ccid-card-emulated.c | 4 ++--
 hw/usb/ccid-card-passthru.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 3213f9f..abb2773 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -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[] = {
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 2eacea7..2bd9cb2 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -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 = {
-- 
1.9.1



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

* Re: [Qemu-trivial] [Qemu-devel] [PATCH] usb: Change *_exitfn return type from void to int
  2016-09-30 17:51 [Qemu-trivial] [PATCH] usb: Change *_exitfn return type from void to int Akanksha Srivastava
@ 2016-09-30 18:06 ` Jonathan Neuschäfer
  2016-09-30 18:46 ` Eric Blake
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Neuschäfer @ 2016-09-30 18:06 UTC (permalink / raw)
  To: Akanksha Srivastava; +Cc: qemu-devel, qemu-trivial, kraxel

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

On Fri, Sep 30, 2016 at 11:21:35PM +0530, Akanksha Srivastava wrote:
> Subject: [Qemu-devel] [PATCH] usb: Change *_exitfn return type from void to int

This should read "from int to void", I guess.

> The *_exitfn functions cannot fail and should not be
> returning int.
> Suggested as a Bite-sized task
> Signed-off-by: Akanksha Srivastava <akanksha.dlf@gmail.com>
> ---
>  hw/usb/ccid-card-emulated.c | 4 ++--
>  hw/usb/ccid-card-passthru.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
[...]
> -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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [Qemu-trivial] [Qemu-devel] [PATCH] usb: Change *_exitfn return type from void to int
  2016-09-30 17:51 [Qemu-trivial] [PATCH] usb: Change *_exitfn return type from void to int Akanksha Srivastava
  2016-09-30 18:06 ` [Qemu-trivial] [Qemu-devel] " Jonathan Neuschäfer
@ 2016-09-30 18:46 ` Eric Blake
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-09-30 18:46 UTC (permalink / raw)
  To: Akanksha Srivastava, qemu-devel; +Cc: qemu-trivial, kraxel


[-- Attachment #1.1: Type: text/plain, Size: 2088 bytes --]

On 09/30/2016 12:51 PM, Akanksha Srivastava wrote:
> The *_exitfn functions cannot fail and should not be
> returning int.
> Suggested as a Bite-sized task
> Signed-off-by: Akanksha Srivastava <akanksha.dlf@gmail.com>
> ---
>  hw/usb/ccid-card-emulated.c | 4 ++--
>  hw/usb/ccid-card-passthru.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
> index 3213f9f..abb2773 100644
> --- a/hw/usb/ccid-card-emulated.c
> +++ b/hw/usb/ccid-card-emulated.c
> @@ -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;
>  }

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.

>  
>  static Property emulated_card_properties[] = {
> diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
> index 2eacea7..2bd9cb2 100644
> --- a/hw/usb/ccid-card-passthru.c
> +++ b/hw/usb/ccid-card-passthru.c
> @@ -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?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

end of thread, other threads:[~2016-09-30 18:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-30 17:51 [Qemu-trivial] [PATCH] usb: Change *_exitfn return type from void to int Akanksha Srivastava
2016-09-30 18:06 ` [Qemu-trivial] [Qemu-devel] " Jonathan Neuschäfer
2016-09-30 18:46 ` Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).