diff mbox series

[kvm-unit-tests,3/7] lib: chr-testdev: Make chr_testdev_init() return status

Message ID 20190124111634.4727-4-alexandru.elisei@arm.com (mailing list archive)
State New, archived
Headers show
Series arm/arm64: Add support for running under kvmtool | expand

Commit Message

Alexandru Elisei Jan. 24, 2019, 11:16 a.m. UTC
Make chr_testdev_init() return 0 (success) if the virtio console was
initialized properly, otherwise return -1 (failure).

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 lib/chr-testdev.h | 2 +-
 lib/chr-testdev.c | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Andrew Jones Jan. 24, 2019, 12:56 p.m. UTC | #1
On Thu, Jan 24, 2019 at 11:16:30AM +0000, Alexandru Elisei wrote:
> Make chr_testdev_init() return 0 (success) if the virtio console was
> initialized properly, otherwise return -1 (failure).
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  lib/chr-testdev.h | 2 +-
>  lib/chr-testdev.c | 8 +++++---
>  2 files changed, 6 insertions(+), 4 deletions(-)

This patch isn't necessary. I'll explain why in patch 5/7.

> 
> diff --git a/lib/chr-testdev.h b/lib/chr-testdev.h
> index ffd9a851aa9b..fdd0582e2da1 100644
> --- a/lib/chr-testdev.h
> +++ b/lib/chr-testdev.h
> @@ -9,6 +9,6 @@
>   *
>   * This work is licensed under the terms of the GNU LGPL, version 2.
>   */
> -extern void chr_testdev_init(void);
> +extern int chr_testdev_init(void);
>  extern void chr_testdev_exit(int code);
>  #endif
> diff --git a/lib/chr-testdev.c b/lib/chr-testdev.c
> index 6890f63c8b29..26e14301e3db 100644
> --- a/lib/chr-testdev.c
> +++ b/lib/chr-testdev.c
> @@ -47,7 +47,7 @@ out:
>  	spin_unlock(&lock);
>  }
>  
> -void chr_testdev_init(void)
> +int chr_testdev_init(void)
>  {
>  	const char *io_names[] = { "input", "output" };
>  	struct virtqueue *vqs[2];
> @@ -57,7 +57,7 @@ void chr_testdev_init(void)
>  	if (vcon == NULL) {
>  		printf("%s: %s: can't find a virtio-console\n",
>  				__func__, TESTDEV_NAME);
> -		return;
> +		return -1;
>  	}
>  
>  	ret = vcon->config->find_vqs(vcon, 2, vqs, NULL, io_names);
> @@ -65,9 +65,11 @@ void chr_testdev_init(void)
>  		printf("%s: %s: can't init virtqueues\n",
>  				__func__, TESTDEV_NAME);
>  		vcon = NULL;
> -		return;
> +		return -1;
>  	}
>  
>  	in_vq = vqs[0];
>  	out_vq = vqs[1];
> +
> +	return 0;
>  }
> -- 
> 2.17.0
>
diff mbox series

Patch

diff --git a/lib/chr-testdev.h b/lib/chr-testdev.h
index ffd9a851aa9b..fdd0582e2da1 100644
--- a/lib/chr-testdev.h
+++ b/lib/chr-testdev.h
@@ -9,6 +9,6 @@ 
  *
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
-extern void chr_testdev_init(void);
+extern int chr_testdev_init(void);
 extern void chr_testdev_exit(int code);
 #endif
diff --git a/lib/chr-testdev.c b/lib/chr-testdev.c
index 6890f63c8b29..26e14301e3db 100644
--- a/lib/chr-testdev.c
+++ b/lib/chr-testdev.c
@@ -47,7 +47,7 @@  out:
 	spin_unlock(&lock);
 }
 
-void chr_testdev_init(void)
+int chr_testdev_init(void)
 {
 	const char *io_names[] = { "input", "output" };
 	struct virtqueue *vqs[2];
@@ -57,7 +57,7 @@  void chr_testdev_init(void)
 	if (vcon == NULL) {
 		printf("%s: %s: can't find a virtio-console\n",
 				__func__, TESTDEV_NAME);
-		return;
+		return -1;
 	}
 
 	ret = vcon->config->find_vqs(vcon, 2, vqs, NULL, io_names);
@@ -65,9 +65,11 @@  void chr_testdev_init(void)
 		printf("%s: %s: can't init virtqueues\n",
 				__func__, TESTDEV_NAME);
 		vcon = NULL;
-		return;
+		return -1;
 	}
 
 	in_vq = vqs[0];
 	out_vq = vqs[1];
+
+	return 0;
 }