summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2009-07-25 11:15:56 +0000
committerratchov <ratchov@openbsd.org>2009-07-25 11:15:56 +0000
commit4c2441987b72c7cee8f11767b3c3ae3149d21b37 (patch)
tree32448133fb4e2a72eb7777eb5f9772aea5c0dc8c /lib
parentsio_open returns a pointer so the < 0 comparison is wrong (diff)
downloadwireguard-openbsd-4c2441987b72c7cee8f11767b3c3ae3149d21b37.tar.xz
wireguard-openbsd-4c2441987b72c7cee8f11767b3c3ae3149d21b37.zip
use const qualifier in libsndio, making it slightly more consistent
with open(2) and write(2) syscalls. from Thomas Pfaff, jakemsr is fine with it
Diffstat (limited to 'lib')
-rw-r--r--lib/libsndio/aucat.c8
-rw-r--r--lib/libsndio/mio.c6
-rw-r--r--lib/libsndio/mio_open.36
-rw-r--r--lib/libsndio/mio_priv.h8
-rw-r--r--lib/libsndio/mio_rmidi.c8
-rw-r--r--lib/libsndio/mio_thru.c8
-rw-r--r--lib/libsndio/sio_open.36
-rw-r--r--lib/libsndio/sndio.c8
-rw-r--r--lib/libsndio/sndio_priv.h8
-rw-r--r--lib/libsndio/sun.c10
10 files changed, 38 insertions, 38 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c
index 5e249f35961..78c9bcfc85a 100644
--- a/lib/libsndio/aucat.c
+++ b/lib/libsndio/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.22 2009/07/25 08:44:26 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.23 2009/07/25 11:15:56 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -50,7 +50,7 @@ static int aucat_setpar(struct sio_hdl *, struct sio_par *);
static int aucat_getpar(struct sio_hdl *, struct sio_par *);
static int aucat_getcap(struct sio_hdl *, struct sio_cap *);
static size_t aucat_read(struct sio_hdl *, void *, size_t);
-static size_t aucat_write(struct sio_hdl *, void *, size_t);
+static size_t aucat_write(struct sio_hdl *, const void *, size_t);
static int aucat_pollfd(struct sio_hdl *, struct pollfd *, int);
static int aucat_revents(struct sio_hdl *, struct pollfd *);
static int aucat_setvol(struct sio_hdl *, unsigned);
@@ -167,7 +167,7 @@ aucat_runmsg(struct aucat_hdl *hdl)
}
struct sio_hdl *
-sio_open_aucat(char *str, unsigned mode, int nbio)
+sio_open_aucat(const char *str, unsigned mode, int nbio)
{
extern char *__progname;
int s;
@@ -524,7 +524,7 @@ aucat_buildmsg(struct aucat_hdl *hdl, size_t len)
}
static size_t
-aucat_write(struct sio_hdl *sh, void *buf, size_t len)
+aucat_write(struct sio_hdl *sh, const void *buf, size_t len)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
ssize_t n;
diff --git a/lib/libsndio/mio.c b/lib/libsndio/mio.c
index b03582d1635..18720ef351d 100644
--- a/lib/libsndio/mio.c
+++ b/lib/libsndio/mio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mio.c,v 1.1 2009/07/25 08:44:26 ratchov Exp $ */
+/* $OpenBSD: mio.c,v 1.2 2009/07/25 11:15:56 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -36,7 +36,7 @@ int mio_debug = -1;
#endif
struct mio_hdl *
-mio_open(char *str, unsigned mode, int nbio)
+mio_open(const char *str, unsigned mode, int nbio)
{
static char prefix_midithru[] = "midithru";
static char prefix_rmidi[] = "rmidi";
@@ -137,7 +137,7 @@ mio_read(struct mio_hdl *hdl, void *buf, size_t len)
}
size_t
-mio_write(struct mio_hdl *hdl, void *buf, size_t len)
+mio_write(struct mio_hdl *hdl, const void *buf, size_t len)
{
if (hdl->eof) {
DPRINTF("mio_write: eof\n");
diff --git a/lib/libsndio/mio_open.3 b/lib/libsndio/mio_open.3
index d8ac43dc04c..e064aca129b 100644
--- a/lib/libsndio/mio_open.3
+++ b/lib/libsndio/mio_open.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mio_open.3,v 1.1 2009/07/25 08:44:26 ratchov Exp $
+.\" $OpenBSD: mio_open.3,v 1.2 2009/07/25 11:15:56 ratchov Exp $
.\"
.\" Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
.\"
@@ -30,13 +30,13 @@
.Sh SYNOPSIS
.Fd #include <sndio.h>
.Ft "struct mio_hdl *"
-.Fn "mio_open" "char *name" "unsigned mode" "int nbio_flag"
+.Fn "mio_open" "const char *name" "unsigned mode" "int nbio_flag"
.Ft "void"
.Fn "mio_close" "struct mio_hdl *hdl"
.Ft "size_t"
.Fn "mio_read" "struct mio_hdl *hdl" "void *addr" "size_t nbytes"
.Ft "size_t"
-.Fn "mio_write" "struct mio_hdl *hdl" "void *addr" "size_t nbytes"
+.Fn "mio_write" "struct mio_hdl *hdl" "const void *addr" "size_t nbytes"
.Ft "int"
.Fn "mio_nfds" "struct mio_hdl *hdl"
.Ft "int"
diff --git a/lib/libsndio/mio_priv.h b/lib/libsndio/mio_priv.h
index 240267333ba..e5c76553888 100644
--- a/lib/libsndio/mio_priv.h
+++ b/lib/libsndio/mio_priv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mio_priv.h,v 1.1 2009/07/25 08:44:26 ratchov Exp $ */
+/* $OpenBSD: mio_priv.h,v 1.2 2009/07/25 11:15:56 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -51,14 +51,14 @@ struct mio_hdl {
*/
struct mio_ops {
void (*close)(struct mio_hdl *);
- size_t (*write)(struct mio_hdl *, void *, size_t);
+ size_t (*write)(struct mio_hdl *, const void *, size_t);
size_t (*read)(struct mio_hdl *, void *, size_t);
int (*pollfd)(struct mio_hdl *, struct pollfd *, int);
int (*revents)(struct mio_hdl *, struct pollfd *);
};
-struct mio_hdl *mio_open_rmidi(char *, unsigned, int);
-struct mio_hdl *mio_open_thru(char *, unsigned, int);
+struct mio_hdl *mio_open_rmidi(const char *, unsigned, int);
+struct mio_hdl *mio_open_thru(const char *, unsigned, int);
void mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int);
void mio_destroy(struct mio_hdl *);
diff --git a/lib/libsndio/mio_rmidi.c b/lib/libsndio/mio_rmidi.c
index 9aa460633e4..7db975bdb50 100644
--- a/lib/libsndio/mio_rmidi.c
+++ b/lib/libsndio/mio_rmidi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mio_rmidi.c,v 1.1 2009/07/25 08:44:26 ratchov Exp $ */
+/* $OpenBSD: mio_rmidi.c,v 1.2 2009/07/25 11:15:56 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -37,7 +37,7 @@ struct rmidi_hdl {
static void rmidi_close(struct mio_hdl *);
static size_t rmidi_read(struct mio_hdl *, void *, size_t);
-static size_t rmidi_write(struct mio_hdl *, void *, size_t);
+static size_t rmidi_write(struct mio_hdl *, const void *, size_t);
static int rmidi_pollfd(struct mio_hdl *, struct pollfd *, int);
static int rmidi_revents(struct mio_hdl *, struct pollfd *);
@@ -50,7 +50,7 @@ static struct mio_ops rmidi_ops = {
};
struct mio_hdl *
-mio_open_rmidi(char *str, unsigned mode, int nbio)
+mio_open_rmidi(const char *str, unsigned mode, int nbio)
{
int fd, flags;
struct rmidi_hdl *hdl;
@@ -123,7 +123,7 @@ rmidi_read(struct mio_hdl *sh, void *buf, size_t len)
}
static size_t
-rmidi_write(struct mio_hdl *sh, void *buf, size_t len)
+rmidi_write(struct mio_hdl *sh, const void *buf, size_t len)
{
struct rmidi_hdl *hdl = (struct rmidi_hdl *)sh;
ssize_t n;
diff --git a/lib/libsndio/mio_thru.c b/lib/libsndio/mio_thru.c
index d3e2953cf18..a541411a998 100644
--- a/lib/libsndio/mio_thru.c
+++ b/lib/libsndio/mio_thru.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mio_thru.c,v 1.1 2009/07/25 08:44:27 ratchov Exp $ */
+/* $OpenBSD: mio_thru.c,v 1.2 2009/07/25 11:15:56 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -39,7 +39,7 @@ struct thru_hdl {
static void thru_close(struct mio_hdl *);
static size_t thru_read(struct mio_hdl *, void *, size_t);
-static size_t thru_write(struct mio_hdl *, void *, size_t);
+static size_t thru_write(struct mio_hdl *, const void *, size_t);
static int thru_pollfd(struct mio_hdl *, struct pollfd *, int);
static int thru_revents(struct mio_hdl *, struct pollfd *);
@@ -52,7 +52,7 @@ static struct mio_ops thru_ops = {
};
struct mio_hdl *
-mio_open_thru(char *str, unsigned mode, int nbio)
+mio_open_thru(const char *str, unsigned mode, int nbio)
{
extern char *__progname;
struct amsg msg;
@@ -178,7 +178,7 @@ thru_read(struct mio_hdl *sh, void *buf, size_t len)
}
static size_t
-thru_write(struct mio_hdl *sh, void *buf, size_t len)
+thru_write(struct mio_hdl *sh, const void *buf, size_t len)
{
struct thru_hdl *hdl = (struct thru_hdl *)sh;
ssize_t n;
diff --git a/lib/libsndio/sio_open.3 b/lib/libsndio/sio_open.3
index 744a556d009..ce7388e9dca 100644
--- a/lib/libsndio/sio_open.3
+++ b/lib/libsndio/sio_open.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sio_open.3,v 1.20 2009/07/25 08:44:27 ratchov Exp $
+.\" $OpenBSD: sio_open.3,v 1.21 2009/07/25 11:15:56 ratchov Exp $
.\"
.\" Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
.\"
@@ -39,7 +39,7 @@
.Sh SYNOPSIS
.Fd #include <sndio.h>
.Ft "struct sio_hdl *"
-.Fn "sio_open" "char *name" "unsigned mode" "int nbio_flag"
+.Fn "sio_open" "const char *name" "unsigned mode" "int nbio_flag"
.Ft "void"
.Fn "sio_close" "struct sio_hdl *hdl"
.Ft "int"
@@ -55,7 +55,7 @@
.Ft "size_t"
.Fn "sio_read" "struct sio_hdl *hdl" "void *addr" "size_t nbytes"
.Ft "size_t"
-.Fn "sio_write" "struct sio_hdl *hdl" "void *addr" "size_t nbytes"
+.Fn "sio_write" "struct sio_hdl *hdl" "const void *addr" "size_t nbytes"
.Ft "void"
.Fn "sio_onmove" "struct sio_hdl *hdl" "void (*cb)(void *arg, int delta)" "void *arg"
.Ft "int"
diff --git a/lib/libsndio/sndio.c b/lib/libsndio/sndio.c
index c7ab3750c81..d18b0fe8729 100644
--- a/lib/libsndio/sndio.c
+++ b/lib/libsndio/sndio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndio.c,v 1.16 2009/07/25 08:44:27 ratchov Exp $ */
+/* $OpenBSD: sndio.c,v 1.17 2009/07/25 11:15:56 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -165,7 +165,7 @@ done:
}
struct sio_hdl *
-sio_open(char *str, unsigned mode, int nbio)
+sio_open(const char *str, unsigned mode, int nbio)
{
static char prefix_aucat[] = "aucat";
static char prefix_sun[] = "sun";
@@ -410,10 +410,10 @@ sio_read(struct sio_hdl *hdl, void *buf, size_t len)
}
size_t
-sio_write(struct sio_hdl *hdl, void *buf, size_t len)
+sio_write(struct sio_hdl *hdl, const void *buf, size_t len)
{
unsigned n;
- unsigned char *data = buf;
+ const unsigned char *data = buf;
size_t todo = len;
#ifdef DEBUG
struct timeval tv0, tv1, dtv;
diff --git a/lib/libsndio/sndio_priv.h b/lib/libsndio/sndio_priv.h
index f35a31abdfd..4f1c6fa2eb4 100644
--- a/lib/libsndio/sndio_priv.h
+++ b/lib/libsndio/sndio_priv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndio_priv.h,v 1.7 2009/05/15 13:06:40 ratchov Exp $ */
+/* $OpenBSD: sndio_priv.h,v 1.8 2009/07/25 11:15:56 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -67,7 +67,7 @@ struct sio_ops {
int (*setpar)(struct sio_hdl *, struct sio_par *);
int (*getpar)(struct sio_hdl *, struct sio_par *);
int (*getcap)(struct sio_hdl *, struct sio_cap *);
- size_t (*write)(struct sio_hdl *, void *, size_t);
+ size_t (*write)(struct sio_hdl *, const void *, size_t);
size_t (*read)(struct sio_hdl *, void *, size_t);
int (*start)(struct sio_hdl *);
int (*stop)(struct sio_hdl *);
@@ -77,8 +77,8 @@ struct sio_ops {
void (*getvol)(struct sio_hdl *);
};
-struct sio_hdl *sio_open_aucat(char *, unsigned, int);
-struct sio_hdl *sio_open_sun(char *, unsigned, int);
+struct sio_hdl *sio_open_aucat(const char *, unsigned, int);
+struct sio_hdl *sio_open_sun(const char *, unsigned, int);
void sio_create(struct sio_hdl *, struct sio_ops *, unsigned, int);
void sio_destroy(struct sio_hdl *);
void sio_onmove_cb(struct sio_hdl *, int);
diff --git a/lib/libsndio/sun.c b/lib/libsndio/sun.c
index b4030c7dc0f..b8600b3b58c 100644
--- a/lib/libsndio/sun.c
+++ b/lib/libsndio/sun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sun.c,v 1.18 2009/07/25 08:44:27 ratchov Exp $ */
+/* $OpenBSD: sun.c,v 1.19 2009/07/25 11:15:56 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -60,7 +60,7 @@ static int sun_setpar(struct sio_hdl *, struct sio_par *);
static int sun_getpar(struct sio_hdl *, struct sio_par *);
static int sun_getcap(struct sio_hdl *, struct sio_cap *);
static size_t sun_read(struct sio_hdl *, void *, size_t);
-static size_t sun_write(struct sio_hdl *, void *, size_t);
+static size_t sun_write(struct sio_hdl *, const void *, size_t);
static int sun_pollfd(struct sio_hdl *, struct pollfd *, int);
static int sun_revents(struct sio_hdl *, struct pollfd *);
static int sun_setvol(struct sio_hdl *, unsigned);
@@ -342,7 +342,7 @@ sun_setvol(struct sio_hdl *sh, unsigned vol)
}
struct sio_hdl *
-sio_open_sun(char *str, unsigned mode, int nbio)
+sio_open_sun(const char *str, unsigned mode, int nbio)
{
int fd, flags, fullduplex;
struct sun_hdl *hdl;
@@ -734,12 +734,12 @@ sun_autostart(struct sun_hdl *hdl)
}
static size_t
-sun_write(struct sio_hdl *sh, void *buf, size_t len)
+sun_write(struct sio_hdl *sh, const void *buf, size_t len)
{
#define ZERO_NMAX 0x1000
static char zero[ZERO_NMAX];
struct sun_hdl *hdl = (struct sun_hdl *)sh;
- unsigned char *data = buf;
+ const unsigned char *data = buf;
ssize_t n, todo;
while (hdl->offset < 0) {