From 56f1183e7851e5809df811c2785ee1d0444f5d25 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Sat, 4 Nov 2017 09:09:56 +0100 Subject: [PATCH 1/6] add missing HISTORY; based on CVS logs and release announcements. From schwarze@. --- libsndio/mio_open.3 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libsndio/mio_open.3 b/libsndio/mio_open.3 index 06a854d..164560b 100644 --- a/libsndio/mio_open.3 +++ b/libsndio/mio_open.3 @@ -247,3 +247,8 @@ may be a value between 0 and 2. .Xr midi 4 , .Xr sndio 7 , .Xr sndiod 8 +.Sh HISTORY +These functions first appeared in +.Ox 4.7 . +.Sh AUTHORS +.An Alexandre Ratchov Aq Mt ratchov@openbsd.org From 7e19ef6644d16689604d1d5c34702cb21b25f6d6 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Sat, 4 Nov 2017 09:14:29 +0100 Subject: [PATCH 2/6] Make *_getfd() and *_fdopen() public. This allows pledged sndiod to build with the portable library. --- libsndio/mio_rmidi.c | 5 ++++- libsndio/sio_sun.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libsndio/mio_rmidi.c b/libsndio/mio_rmidi.c index 6ffef85..e337b2e 100644 --- a/libsndio/mio_rmidi.c +++ b/libsndio/mio_rmidi.c @@ -135,11 +135,14 @@ mio_rmidi_getfd(const char *str, unsigned int mode, int nbio) return fd; } -static struct mio_hdl * +struct mio_hdl * mio_rmidi_fdopen(int fd, unsigned int mode, int nbio) { struct mio_rmidi_hdl *hdl; +#ifdef DEBUG + _sndio_debug_init(); +#endif hdl = malloc(sizeof(struct mio_rmidi_hdl)); if (hdl == NULL) return NULL; diff --git a/libsndio/sio_sun.c b/libsndio/sio_sun.c index e32cf40..6901b5d 100644 --- a/libsndio/sio_sun.c +++ b/libsndio/sio_sun.c @@ -267,7 +267,7 @@ sio_sun_getcap(struct sio_hdl *sh, struct sio_cap *cap) return 1; } -static int +int sio_sun_getfd(const char *str, unsigned int mode, int nbio) { const char *p; @@ -275,6 +275,9 @@ sio_sun_getfd(const char *str, unsigned int mode, int nbio) unsigned int devnum; int fd, flags; +#ifdef DEBUG + _sndio_debug_init(); +#endif p = _sndio_parsetype(str, "rsnd"); if (p == NULL) { DPRINTF("sio_sun_getfd: %s: \"rsnd\" expected\n", str); @@ -307,11 +310,14 @@ sio_sun_getfd(const char *str, unsigned int mode, int nbio) return fd; } -static struct sio_hdl * +struct sio_hdl * sio_sun_fdopen(int fd, unsigned int mode, int nbio) { struct sio_sun_hdl *hdl; +#ifdef DEBUG + _sndio_debug_init(); +#endif hdl = malloc(sizeof(struct sio_sun_hdl)); if (hdl == NULL) return NULL; From 0663b9b2b72242f17f3ff9d1821c04dc3a602485 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Sat, 4 Nov 2017 09:34:30 +0100 Subject: [PATCH 3/6] make mio_rmidi_getfd() non-static, missed in last commit --- libsndio/mio_rmidi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsndio/mio_rmidi.c b/libsndio/mio_rmidi.c index e337b2e..f9d7722 100644 --- a/libsndio/mio_rmidi.c +++ b/libsndio/mio_rmidi.c @@ -66,7 +66,7 @@ static struct mio_ops mio_rmidi_ops = { mio_rmidi_revents }; -static int +int mio_rmidi_getfd(const char *str, unsigned int mode, int nbio) { const char *p; From 93b9e03596e3af13fc92ef66d314141fcaa74f38 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Sat, 4 Nov 2017 09:35:05 +0100 Subject: [PATCH 4/6] expose *_getfd() and *_fdopen() prototypes --- libsndio/sndio.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libsndio/sndio.h b/libsndio/sndio.h index bd79202..19e44fc 100644 --- a/libsndio/sndio.h +++ b/libsndio/sndio.h @@ -144,6 +144,11 @@ int mio_pollfd(struct mio_hdl *, struct pollfd *, int); int mio_revents(struct mio_hdl *, struct pollfd *); int mio_eof(struct mio_hdl *); +int mio_rmidi_getfd(const char *, unsigned int, int); +struct mio_hdl *mio_rmidi_fdopen(int, unsigned int, int); +int sio_sun_getfd(const char *, unsigned int, int); +struct sio_hdl *sio_sun_fdopen(int, unsigned int, int); + #ifdef __cplusplus } #endif From 053efb5710767d72285701d4ea733de1bf6063c1 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Sat, 4 Nov 2017 10:38:01 +0100 Subject: [PATCH 5/6] no need to check if pointer passed to free() is NULL --- libsndio/aucat.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libsndio/aucat.c b/libsndio/aucat.c index 1873e67..2a61514 100644 --- a/libsndio/aucat.c +++ b/libsndio/aucat.c @@ -335,10 +335,8 @@ bad_gen: unlink(tmp); } done: - if (tmp) - free(tmp); - if (path) - free(path); + free(tmp); + free(path); return 1; } From c0767fd17115504f483603018d856d611084f0a0 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Sat, 4 Nov 2017 10:40:00 +0100 Subject: [PATCH 6/6] call _sndio_debug_init() in mio_rmidi_getfd() --- libsndio/mio_rmidi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsndio/mio_rmidi.c b/libsndio/mio_rmidi.c index f9d7722..e0302cc 100644 --- a/libsndio/mio_rmidi.c +++ b/libsndio/mio_rmidi.c @@ -77,6 +77,9 @@ mio_rmidi_getfd(const char *str, unsigned int mode, int nbio) #endif int fd, flags; +#ifdef DEBUG + _sndio_debug_init(); +#endif p = _sndio_parsetype(str, "rmidi"); if (p == NULL) { DPRINTF("mio_rmidi_getfd: %s: \"rsnd\" expected\n", str);