Clean up error handling in rumpuser_init()

This commit is contained in:
justin 2014-07-25 14:00:31 +00:00
parent 3d4f4e180c
commit 28e2f06e08
3 changed files with 16 additions and 12 deletions

View File

@ -66,7 +66,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
__RCSID("$NetBSD: rumpfiber.c,v 1.2 2014/07/22 22:41:58 justin Exp $");
__RCSID("$NetBSD: rumpfiber.c,v 1.3 2014/07/25 14:00:31 justin Exp $");
#endif /* !lint */
#include <sys/ioctl.h>
@ -410,14 +410,16 @@ struct rumpuser_hyperup rumpuser__hyp;
int
rumpuser_init(int version, const struct rumpuser_hyperup *hyp)
{
int rv;
if (version != RUMPUSER_VERSION) {
printk("rumpuser version mismatch\n");
return 1;
abort();
}
if (rumpuser__random_init() != 0) {
return 1;
rv = rumpuser__random_init();
if (rv != 0) {
ET(rv);
}
rumpuser__hyp = *hyp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpuser.c,v 1.62 2014/07/22 22:41:58 justin Exp $ */
/* $NetBSD: rumpuser.c,v 1.63 2014/07/25 14:00:31 justin Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
__RCSID("$NetBSD: rumpuser.c,v 1.62 2014/07/22 22:41:58 justin Exp $");
__RCSID("$NetBSD: rumpuser.c,v 1.63 2014/07/25 14:00:31 justin Exp $");
#endif /* !lint */
#include <sys/stat.h>
@ -57,15 +57,17 @@ struct rumpuser_hyperup rumpuser__hyp;
int
rumpuser_init(int version, const struct rumpuser_hyperup *hyp)
{
int rv;
if (version != RUMPUSER_VERSION) {
fprintf(stderr, "rumpuser mismatch, kern: %d, hypervisor %d\n",
version, RUMPUSER_VERSION);
return 1;
abort();
}
if (rumpuser__random_init() != 0) {
return 1;
rv = rumpuser__random_init();
if (rv != 0) {
ET(rv);
}
rumpuser__thrinit();

View File

@ -26,7 +26,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
__RCSID("$NetBSD: rumpuser_random.c,v 1.1 2014/07/22 22:41:58 justin Exp $");
__RCSID("$NetBSD: rumpuser_random.c,v 1.2 2014/07/25 14:00:31 justin Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -64,7 +64,7 @@ rumpuser__random_init(void)
random_fd = open(random_device, O_RDONLY);
if (random_fd < 0) {
fprintf(stderr, "random init open failed\n");
return 1;
return errno;
}
return 0;
}
@ -87,5 +87,5 @@ rumpuser_getrandom(void *buf, size_t buflen, int flags, size_t *retp)
*retp = buflen;
#endif
ET(0);
return 0;
}