diff options
Diffstat (limited to 'src/pulsecore/iochannel.c')
| -rw-r--r-- | src/pulsecore/iochannel.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/src/pulsecore/iochannel.c b/src/pulsecore/iochannel.c index 6f58ae75..2f586cbf 100644 --- a/src/pulsecore/iochannel.c +++ b/src/pulsecore/iochannel.c @@ -27,7 +27,6 @@ #endif #include <stdlib.h> -#include <assert.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> @@ -47,6 +46,7 @@ #include <pulsecore/core-util.h> #include <pulsecore/socket-util.h> #include <pulsecore/log.h> +#include <pulsecore/macro.h> #include "iochannel.h" @@ -68,11 +68,11 @@ struct pa_iochannel { }; static void enable_mainloop_sources(pa_iochannel *io) { - assert(io); + pa_assert(io); if (io->input_event == io->output_event && io->input_event) { pa_io_event_flags_t f = PA_IO_EVENT_NULL; - assert(io->input_event); + pa_assert(io->input_event); if (!io->readable) f |= PA_IO_EVENT_INPUT; @@ -92,10 +92,10 @@ static void callback(pa_mainloop_api* m, pa_io_event *e, int fd, pa_io_event_fla pa_iochannel *io = userdata; int changed = 0; - assert(m); - assert(e); - assert(fd >= 0); - assert(userdata); + pa_assert(m); + pa_assert(e); + pa_assert(fd >= 0); + pa_assert(userdata); if ((f & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR)) && !io->hungup) { io->hungup = 1; @@ -105,13 +105,13 @@ static void callback(pa_mainloop_api* m, pa_io_event *e, int fd, pa_io_event_fla if ((f & PA_IO_EVENT_INPUT) && !io->readable) { io->readable = 1; changed = 1; - assert(e == io->input_event); + pa_assert(e == io->input_event); } if ((f & PA_IO_EVENT_OUTPUT) && !io->writable) { io->writable = 1; changed = 1; - assert(e == io->output_event); + pa_assert(e == io->output_event); } if (changed) { @@ -125,8 +125,8 @@ static void callback(pa_mainloop_api* m, pa_io_event *e, int fd, pa_io_event_fla pa_iochannel* pa_iochannel_new(pa_mainloop_api*m, int ifd, int ofd) { pa_iochannel *io; - assert(m); - assert(ifd >= 0 || ofd >= 0); + pa_assert(m); + pa_assert(ifd >= 0 || ofd >= 0); io = pa_xnew(pa_iochannel, 1); io->ifd = ifd; @@ -144,7 +144,7 @@ pa_iochannel* pa_iochannel_new(pa_mainloop_api*m, int ifd, int ofd) { io->input_event = io->output_event = NULL; if (ifd == ofd) { - assert(ifd >= 0); + pa_assert(ifd >= 0); pa_make_nonblock_fd(io->ifd); io->input_event = io->output_event = m->io_new(m, ifd, PA_IO_EVENT_INPUT|PA_IO_EVENT_OUTPUT, callback, io); } else { @@ -164,7 +164,7 @@ pa_iochannel* pa_iochannel_new(pa_mainloop_api*m, int ifd, int ofd) { } void pa_iochannel_free(pa_iochannel*io) { - assert(io); + pa_assert(io); if (io->input_event) io->mainloop->io_free(io->input_event); @@ -183,19 +183,19 @@ void pa_iochannel_free(pa_iochannel*io) { } int pa_iochannel_is_readable(pa_iochannel*io) { - assert(io); + pa_assert(io); return io->readable || io->hungup; } int pa_iochannel_is_writable(pa_iochannel*io) { - assert(io); + pa_assert(io); return io->writable && !io->hungup; } int pa_iochannel_is_hungup(pa_iochannel*io) { - assert(io); + pa_assert(io); return io->hungup; } @@ -203,10 +203,10 @@ int pa_iochannel_is_hungup(pa_iochannel*io) { ssize_t pa_iochannel_write(pa_iochannel*io, const void*data, size_t l) { ssize_t r; - assert(io); - assert(data); - assert(l); - assert(io->ofd >= 0); + pa_assert(io); + pa_assert(data); + pa_assert(l); + pa_assert(io->ofd >= 0); r = pa_write(io->ofd, data, l, &io->ofd_type); if (r >= 0) { @@ -220,9 +220,9 @@ ssize_t pa_iochannel_write(pa_iochannel*io, const void*data, size_t l) { ssize_t pa_iochannel_read(pa_iochannel*io, void*data, size_t l) { ssize_t r; - assert(io); - assert(data); - assert(io->ifd >= 0); + pa_assert(io); + pa_assert(data); + pa_assert(io->ifd >= 0); r = pa_read(io->ifd, data, l, &io->ifd_type); if (r >= 0) { @@ -239,9 +239,9 @@ int pa_iochannel_creds_supported(pa_iochannel *io) { struct sockaddr_un sa; socklen_t l; - assert(io); - assert(io->ifd >= 0); - assert(io->ofd == io->ifd); + pa_assert(io); + pa_assert(io->ifd >= 0); + pa_assert(io->ofd == io->ifd); l = sizeof(sa); @@ -254,8 +254,8 @@ int pa_iochannel_creds_supported(pa_iochannel *io) { int pa_iochannel_creds_enable(pa_iochannel *io) { int t = 1; - assert(io); - assert(io->ifd >= 0); + pa_assert(io); + pa_assert(io->ifd >= 0); if (setsockopt(io->ifd, SOL_SOCKET, SO_PASSCRED, &t, sizeof(t)) < 0) { pa_log_error("setsockopt(SOL_SOCKET, SO_PASSCRED): %s", pa_cstrerror(errno)); @@ -273,10 +273,10 @@ ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l struct ucred *u; struct cmsghdr *cmsg; - assert(io); - assert(data); - assert(l); - assert(io->ofd >= 0); + pa_assert(io); + pa_assert(data); + pa_assert(l); + pa_assert(io->ofd >= 0); memset(&iov, 0, sizeof(iov)); iov.iov_base = (void*) data; @@ -322,12 +322,12 @@ ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_cr struct iovec iov; uint8_t cmsg_data[CMSG_SPACE(sizeof(struct ucred))]; - assert(io); - assert(data); - assert(l); - assert(io->ifd >= 0); - assert(creds); - assert(creds_valid); + pa_assert(io); + pa_assert(data); + pa_assert(l); + pa_assert(io->ifd >= 0); + pa_assert(creds); + pa_assert(creds_valid); memset(&iov, 0, sizeof(iov)); iov.iov_base = data; @@ -353,7 +353,7 @@ ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_cr if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDENTIALS) { struct ucred u; - assert(cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))); + pa_assert(cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))); memcpy(&u, CMSG_DATA(cmsg), sizeof(struct ucred)); creds->gid = u.gid; @@ -373,46 +373,46 @@ ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_cr #endif /* HAVE_CREDS */ void pa_iochannel_set_callback(pa_iochannel*io, pa_iochannel_cb_t _callback, void *userdata) { - assert(io); + pa_assert(io); io->callback = _callback; io->userdata = userdata; } void pa_iochannel_set_noclose(pa_iochannel*io, int b) { - assert(io); + pa_assert(io); io->no_close = b; } void pa_iochannel_socket_peer_to_string(pa_iochannel*io, char*s, size_t l) { - assert(io); - assert(s); - assert(l); + pa_assert(io); + pa_assert(s); + pa_assert(l); pa_socket_peer_to_string(io->ifd, s, l); } int pa_iochannel_socket_set_rcvbuf(pa_iochannel *io, size_t l) { - assert(io); + pa_assert(io); return pa_socket_set_rcvbuf(io->ifd, l); } int pa_iochannel_socket_set_sndbuf(pa_iochannel *io, size_t l) { - assert(io); + pa_assert(io); return pa_socket_set_sndbuf(io->ofd, l); } pa_mainloop_api* pa_iochannel_get_mainloop_api(pa_iochannel *io) { - assert(io); + pa_assert(io); return io->mainloop; } int pa_iochannel_get_recv_fd(pa_iochannel *io) { - assert(io); + pa_assert(io); return io->ifd; } |
