diff options
Diffstat (limited to 'usr.sbin/ldomctl')
-rw-r--r-- | usr.sbin/ldomctl/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/ldomctl/ds.c | 9 | ||||
-rw-r--r-- | usr.sbin/ldomctl/ldomctl.c | 5 | ||||
-rw-r--r-- | usr.sbin/ldomctl/mdesc.c | 37 | ||||
-rw-r--r-- | usr.sbin/ldomctl/mdesc.h | 4 | ||||
-rw-r--r-- | usr.sbin/ldomctl/util.c | 55 | ||||
-rw-r--r-- | usr.sbin/ldomctl/util.h | 30 |
7 files changed, 94 insertions, 50 deletions
diff --git a/usr.sbin/ldomctl/Makefile b/usr.sbin/ldomctl/Makefile index cf0e9217fb9..1af299a8a04 100644 --- a/usr.sbin/ldomctl/Makefile +++ b/usr.sbin/ldomctl/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.3 2012/10/21 12:47:58 kettenis Exp $ +# $OpenBSD: Makefile,v 1.4 2012/10/21 12:56:45 kettenis Exp $ PROG= ldomctl -SRCS= ldomctl.c ds.c mdesc.c +SRCS= ldomctl.c ds.c mdesc.c util.c NOMAN= CFLAGS+= -Wall DEBUG= -g diff --git a/usr.sbin/ldomctl/ds.c b/usr.sbin/ldomctl/ds.c index 27d3bfa35c6..692fda79c41 100644 --- a/usr.sbin/ldomctl/ds.c +++ b/usr.sbin/ldomctl/ds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ds.c,v 1.1 2012/10/21 12:47:58 kettenis Exp $ */ +/* $OpenBSD: ds.c,v 1.2 2012/10/21 12:56:45 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -25,9 +25,7 @@ #include <unistd.h> #include "ds.h" -#include "mdesc.h" - -#define DPRINTF(x) printf x +#include "util.h" void pri_start(struct ldc_conn *, uint64_t); void pri_rx_data(struct ldc_conn *, uint64_t, void *, size_t); @@ -37,9 +35,6 @@ struct ds_service ds_service[] = { { NULL, 0, 0 } }; -#define min(a, b) ((a) < (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) - void ldc_rx_ctrl_vers(struct ldc_conn *, struct ldc_pkt *); void ldc_rx_ctrl_rtr(struct ldc_conn *, struct ldc_pkt *); void ldc_rx_ctrl_rts(struct ldc_conn *, struct ldc_pkt *); diff --git a/usr.sbin/ldomctl/ldomctl.c b/usr.sbin/ldomctl/ldomctl.c index 78521976215..8fc2de94722 100644 --- a/usr.sbin/ldomctl/ldomctl.c +++ b/usr.sbin/ldomctl/ldomctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldomctl.c,v 1.7 2012/10/21 12:47:58 kettenis Exp $ */ +/* $OpenBSD: ldomctl.c,v 1.8 2012/10/21 12:56:45 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -27,8 +27,7 @@ #include "ds.h" #include "mdesc.h" - -#define DPRINTF(x) printf x +#include "util.h" struct hv_io { uint64_t hi_cookie; diff --git a/usr.sbin/ldomctl/mdesc.c b/usr.sbin/ldomctl/mdesc.c index 30ef02a653e..07dfd60ba25 100644 --- a/usr.sbin/ldomctl/mdesc.c +++ b/usr.sbin/ldomctl/mdesc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdesc.c,v 1.1 2012/10/15 20:28:50 kettenis Exp $ */ +/* $OpenBSD: mdesc.c,v 1.2 2012/10/21 12:56:45 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -26,40 +26,7 @@ #include <string.h> #include "mdesc.h" - -#define roundup(n, m) (((n) + ((m) - 1)) & ~((m) - 1)) - -void * -xmalloc(size_t size) -{ - void *p; - - p = malloc(size); - if (p == NULL) - err(1, NULL); - return p; -} - -void * -xzalloc(size_t size) -{ - void *p; - - p = xmalloc(size); - memset(p, 0, size); - return p; -} - -char * -xstrdup(const char *s) -{ - char *p; - - p = strdup(s); - if (p == NULL) - err(1, NULL); - return p; -} +#include "util.h" struct md_name * md_find_name(struct md *md, const char *str) diff --git a/usr.sbin/ldomctl/mdesc.h b/usr.sbin/ldomctl/mdesc.h index 3c9bbcbf790..586d37c87b4 100644 --- a/usr.sbin/ldomctl/mdesc.h +++ b/usr.sbin/ldomctl/mdesc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mdesc.h,v 1.1 2012/10/15 20:28:50 kettenis Exp $ */ +/* $OpenBSD: mdesc.h,v 1.2 2012/10/21 12:56:45 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -118,5 +118,3 @@ bool md_get_prop_str(struct md *, struct md_node *, const char *, const char **); struct md *md_ingest(void *, size_t); - -void *xmalloc(size_t); diff --git a/usr.sbin/ldomctl/util.c b/usr.sbin/ldomctl/util.c new file mode 100644 index 00000000000..cff44ee1b95 --- /dev/null +++ b/usr.sbin/ldomctl/util.c @@ -0,0 +1,55 @@ +/* $OpenBSD: util.c,v 1.1 2012/10/21 12:56:45 kettenis Exp $ */ + +/* + * Copyright (c) 2012 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <err.h> +#include <stdlib.h> +#include <string.h> + +#include "util.h" + +void * +xmalloc(size_t size) +{ + void *p; + + p = malloc(size); + if (p == NULL) + err(1, NULL); + return p; +} + +void * +xzalloc(size_t size) +{ + void *p; + + p = xmalloc(size); + memset(p, 0, size); + return p; +} + +char * +xstrdup(const char *s) +{ + char *p; + + p = strdup(s); + if (p == NULL) + err(1, NULL); + return p; +} diff --git a/usr.sbin/ldomctl/util.h b/usr.sbin/ldomctl/util.h new file mode 100644 index 00000000000..e46dfb8b028 --- /dev/null +++ b/usr.sbin/ldomctl/util.h @@ -0,0 +1,30 @@ +/* $OpenBSD: util.h,v 1.1 2012/10/21 12:56:45 kettenis Exp $ */ + +/* + * Copyright (c) 2012 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <stddef.h> + +#define DPRINTF(x) printf x + +void *xmalloc(size_t); +void *xzalloc(size_t); +char *xstrdup(const char *); + +#define min(a, b) ((a) < (b) ? (a) : (b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) + +#define roundup(n, m) (((n) + ((m) - 1)) & ~((m) - 1)) |