From 4e3dc7ce68561c16254712d713b2ccd472b8afe7 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 22 May 2006 15:20:46 +0000 Subject: Wrap strerror() in a function that makes it thread safe and converts the output to UTF-8. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@945 fefdeb5f-60dc-0310-8127-8f9354f1896f --- configure.ac | 3 + src/Makefile.am | 1 + src/daemon/caps.c | 4 +- src/daemon/cpulimit.c | 4 +- src/daemon/daemon-conf.c | 3 +- src/daemon/main.c | 5 +- src/modules/module-alsa-source.c | 3 +- src/modules/module-detect.c | 7 ++- src/modules/module-esound-compat-spawnfd.c | 4 +- src/modules/module-esound-compat-spawnpid.c | 4 +- src/modules/module-esound-sink.c | 11 ++-- src/modules/module-jack-sink.c | 3 +- src/modules/module-jack-source.c | 3 +- src/modules/module-match.c | 3 +- src/modules/module-mmkbd-evdev.c | 13 +++-- src/modules/module-oss-mmap.c | 29 +++++----- src/modules/module-oss.c | 17 +++--- src/modules/module-pipe-sink.c | 7 ++- src/modules/module-pipe-source.c | 7 ++- src/modules/module-protocol-stub.c | 5 +- src/modules/module-solaris.c | 15 ++--- src/modules/module-volume-restore.c | 5 +- src/modules/oss-util.c | 20 ++++--- src/modules/rtp/module-rtp-recv.c | 9 +-- src/modules/rtp/module-rtp-send.c | 11 ++-- src/modules/rtp/rtp.c | 8 ++- src/modules/rtp/sap.c | 9 +-- src/polyp/client-conf.c | 3 +- src/polyp/context.c | 7 ++- src/polyp/error.c | 90 +++++++++++++++++++++++++++++ src/polyp/error.h | 6 ++ src/polyp/mainloop-signal.c | 5 +- src/polyp/mainloop.c | 3 +- src/polyp/util.c | 4 +- src/polypcore/authkey.c | 13 +++-- src/polypcore/cli-command.c | 3 +- src/polypcore/conf-parser.c | 7 ++- src/polypcore/core-scache.c | 5 +- src/polypcore/core-util.c | 31 +++++----- src/polypcore/iochannel.c | 3 +- src/polypcore/ioline.c | 5 +- src/polypcore/log.c | 3 + src/polypcore/pid.c | 25 +++++--- src/polypcore/protocol-esound.c | 13 +++-- src/polypcore/protocol-simple.c | 5 +- src/polypcore/socket-client.c | 9 +-- src/polypcore/socket-server.c | 35 +++++------ src/polypcore/socket-util.c | 3 +- src/utils/pacmd.c | 15 ++--- 49 files changed, 337 insertions(+), 169 deletions(-) diff --git a/configure.ac b/configure.ac index 445e26be..fadc0219 100644 --- a/configure.ac +++ b/configure.ac @@ -242,6 +242,9 @@ AC_CHECK_FUNCS([readlink]) # SUSv2 AC_CHECK_FUNCS([ctime_r usleep]) +# SUSv3 +AC_CHECK_FUNCS([strerror_r]) + # BSD AC_CHECK_FUNCS([lstat]) diff --git a/src/Makefile.am b/src/Makefile.am index e93210aa..30e73512 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -499,6 +499,7 @@ lib_LTLIBRARIES += libpolypcore.la # Some public stuff is used even in the core. libpolypcore_la_SOURCES = \ polyp/channelmap.c polyp/channelmap.h \ + polyp/error.c polyp/error.h \ polyp/mainloop.c polyp/mainloop.h \ polyp/mainloop-api.c polyp/mainloop-api.h \ polyp/mainloop-signal.c polyp/mainloop-signal.h \ diff --git a/src/daemon/caps.c b/src/daemon/caps.c index 8740b7e8..4942868c 100644 --- a/src/daemon/caps.c +++ b/src/daemon/caps.c @@ -32,6 +32,8 @@ #include #endif +#include + #include #include "caps.h" @@ -110,7 +112,7 @@ int pa_drop_caps(void) { cap_clear(caps); if (cap_set_proc(caps) < 0) { - pa_log(__FILE__": failed to drop capabilities: %s", strerror(errno)); + pa_log(__FILE__": failed to drop capabilities: %s", pa_cstrerror(errno)); goto fail; } diff --git a/src/daemon/cpulimit.c b/src/daemon/cpulimit.c index 69973384..2cc37be6 100644 --- a/src/daemon/cpulimit.c +++ b/src/daemon/cpulimit.c @@ -23,6 +23,8 @@ #include #endif +#include + #include #include @@ -169,7 +171,7 @@ int pa_cpu_limit_init(pa_mainloop_api *m) { /* Prepare the main loop pipe */ if (pipe(the_pipe) < 0) { - pa_log(__FILE__": pipe() failed: %s", strerror(errno)); + pa_log(__FILE__": pipe() failed: %s", pa_cstrerror(errno)); return -1; } diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 0f4fcb97..809769f8 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -237,7 +238,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file, "r"); if (!f && errno != ENOENT) { - pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno)); + pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, pa_cstrerror(errno)); goto finish; } diff --git a/src/daemon/main.c b/src/daemon/main.c index b4bc4e00..2fadd496 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -50,6 +50,7 @@ #include "../polypcore/winsock.h" +#include #include #include #include @@ -286,7 +287,7 @@ int main(int argc, char *argv[]) { } if ((child = fork()) < 0) { - pa_log(__FILE__": fork() failed: %s", strerror(errno)); + pa_log(__FILE__": fork() failed: %s", pa_cstrerror(errno)); goto finish; } @@ -297,7 +298,7 @@ int main(int argc, char *argv[]) { daemon_pipe[1] = -1; if (pa_loop_read(daemon_pipe[0], &retval, sizeof(retval)) != sizeof(retval)) { - pa_log(__FILE__": read() failed: %s", strerror(errno)); + pa_log(__FILE__": read() failed: %s", pa_cstrerror(errno)); retval = 1; } diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c index 654f3e49..c72b0322 100644 --- a/src/modules/module-alsa-source.c +++ b/src/modules/module-alsa-source.c @@ -34,6 +34,7 @@ #include +#include #include #include @@ -134,7 +135,7 @@ static void do_read(struct userdata *u) { continue; } - pa_log(__FILE__": snd_pcm_readi() failed: %s", strerror(-frames)); + pa_log(__FILE__": snd_pcm_readi() failed: %s", pa_cstrerror(-frames)); return; } diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 2edbea5e..e4f2e3f9 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -56,7 +57,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (!(f = fopen("/proc/asound/devices", "r"))) { if (errno != ENOENT) - pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s", strerror(errno)); + pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno)); return -1; } @@ -119,7 +120,7 @@ static int detect_oss(pa_core *c, int just_one) { !(f = fopen("/proc/asound/oss/sndstat", "r"))) { if (errno != ENOENT) - pa_log_error(__FILE__": failed to open OSS sndstat device: %s", strerror(errno)); + pa_log_error(__FILE__": failed to open OSS sndstat device: %s", pa_cstrerror(errno)); return -1; } @@ -175,7 +176,7 @@ static int detect_solaris(pa_core *c, int just_one) { if (stat(dev, &s) < 0) { if (errno != ENOENT) - pa_log_error(__FILE__": failed to open device %s: %s", dev, strerror(errno)); + pa_log_error(__FILE__": failed to open device %s: %s", dev, pa_cstrerror(errno)); return -1; } diff --git a/src/modules/module-esound-compat-spawnfd.c b/src/modules/module-esound-compat-spawnfd.c index bf89ca70..f59e9e21 100644 --- a/src/modules/module-esound-compat-spawnfd.c +++ b/src/modules/module-esound-compat-spawnfd.c @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -59,7 +61,7 @@ int pa__init(pa_core *c, pa_module*m) { } if (pa_loop_write(fd, &x, sizeof(x)) != sizeof(x)) - pa_log(__FILE__": WARNING: write(%u, 1, 1) failed: %s", fd, strerror(errno)); + pa_log(__FILE__": WARNING: write(%u, 1, 1) failed: %s", fd, pa_cstrerror(errno)); close(fd); diff --git a/src/modules/module-esound-compat-spawnpid.c b/src/modules/module-esound-compat-spawnpid.c index 895abec3..c14ce12a 100644 --- a/src/modules/module-esound-compat-spawnpid.c +++ b/src/modules/module-esound-compat-spawnpid.c @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -59,7 +61,7 @@ int pa__init(pa_core *c, pa_module*m) { } if (kill(pid, SIGUSR1) < 0) - pa_log(__FILE__": WARNING: kill(%u) failed: %s", pid, strerror(errno)); + pa_log(__FILE__": WARNING: kill(%u) failed: %s", pid, pa_cstrerror(errno)); pa_module_unload_request(m); diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c index cf3ce807..72298679 100644 --- a/src/modules/module-esound-sink.c +++ b/src/modules/module-esound-sink.c @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -128,7 +129,7 @@ static int do_write(struct userdata *u) { assert(u->write_index < u->write_length); if ((r = pa_iochannel_write(u->io, (uint8_t*) u->write_data + u->write_index, u->write_length - u->write_index)) <= 0) { - pa_log(__FILE__": write() failed: %s", strerror(errno)); + pa_log(__FILE__": write() failed: %s", pa_cstrerror(errno)); return -1; } @@ -150,7 +151,7 @@ static int do_write(struct userdata *u) { assert(u->memchunk.memblock && u->memchunk.length); if ((r = pa_iochannel_write(u->io, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length)) < 0) { - pa_log(__FILE__": write() failed: %s", strerror(errno)); + pa_log(__FILE__": write() failed: %s", pa_cstrerror(errno)); return -1; } @@ -175,7 +176,7 @@ static int handle_response(struct userdata *u) { /* Process auth data */ if (!*(int32_t*) u->read_data) { - pa_log(__FILE__": Authentication failed: %s", strerror(errno)); + pa_log(__FILE__": Authentication failed: %s", pa_cstrerror(errno)); return -1; } @@ -245,7 +246,7 @@ static int do_read(struct userdata *u) { assert(u->read_index < u->read_length); if ((r = pa_iochannel_read(u->io, (uint8_t*) u->read_data + u->read_index, u->read_length - u->read_index)) <= 0) { - pa_log(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF"); + pa_log(__FILE__": read() failed: %s", r < 0 ? pa_cstrerror(errno) : "EOF"); cancel(u); return -1; } @@ -305,7 +306,7 @@ static void on_connection(PA_GCC_UNUSED pa_socket_client *c, pa_iochannel*io, vo u->client = NULL; if (!io) { - pa_log(__FILE__": connection failed: %s", strerror(errno)); + pa_log(__FILE__": connection failed: %s", pa_cstrerror(errno)); cancel(u); return; } diff --git a/src/modules/module-jack-sink.c b/src/modules/module-jack-sink.c index 96db837a..db2ba030 100644 --- a/src/modules/module-jack-sink.c +++ b/src/modules/module-jack-sink.c @@ -36,6 +36,7 @@ #include +#include #include #include @@ -272,7 +273,7 @@ int pa__init(pa_core *c, pa_module*m) { pthread_cond_init(&u->cond, NULL); if (pipe(u->pipe_fds) < 0) { - pa_log(__FILE__": pipe() failed: %s", strerror(errno)); + pa_log(__FILE__": pipe() failed: %s", pa_cstrerror(errno)); goto fail; } diff --git a/src/modules/module-jack-source.c b/src/modules/module-jack-source.c index 3d783145..8816fb8a 100644 --- a/src/modules/module-jack-source.c +++ b/src/modules/module-jack-source.c @@ -36,6 +36,7 @@ #include +#include #include #include @@ -270,7 +271,7 @@ int pa__init(pa_core *c, pa_module*m) { pthread_cond_init(&u->cond, NULL); if (pipe(u->pipe_fds) < 0) { - pa_log(__FILE__": pipe() failed: %s", strerror(errno)); + pa_log(__FILE__": pipe() failed: %s", pa_cstrerror(errno)); goto fail; } diff --git a/src/modules/module-match.c b/src/modules/module-match.c index c7ca12a5..f68f0c61 100644 --- a/src/modules/module-match.c +++ b/src/modules/module-match.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -86,7 +87,7 @@ static int load_rules(struct userdata *u, const char *filename) { pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn, "r"); if (!f) { - pa_log(__FILE__": failed to open file '%s': %s", fn, strerror(errno)); + pa_log(__FILE__": failed to open file '%s': %s", fn, pa_cstrerror(errno)); goto finish; } diff --git a/src/modules/module-mmkbd-evdev.c b/src/modules/module-mmkbd-evdev.c index 55f0b2c8..d6c91e2e 100644 --- a/src/modules/module-mmkbd-evdev.c +++ b/src/modules/module-mmkbd-evdev.c @@ -33,6 +33,7 @@ #include +#include #include #include @@ -89,7 +90,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC struct input_event ev; if (pa_loop_read(u->fd, &ev, sizeof(ev)) <= 0) { - pa_log(__FILE__": failed to read from event device: %s", strerror(errno)); + pa_log(__FILE__": failed to read from event device: %s", pa_cstrerror(errno)); goto fail; } @@ -183,19 +184,19 @@ int pa__init(pa_core *c, pa_module*m) { u->fd = -1; if ((u->fd = open(pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), O_RDONLY)) < 0) { - pa_log(__FILE__": failed to open evdev device: %s", strerror(errno)); + pa_log(__FILE__": failed to open evdev device: %s", pa_cstrerror(errno)); goto fail; } if (ioctl(u->fd, EVIOCGVERSION, &version) < 0) { - pa_log(__FILE__": EVIOCGVERSION failed: %s", strerror(errno)); + pa_log(__FILE__": EVIOCGVERSION failed: %s", pa_cstrerror(errno)); goto fail; } pa_log_info(__FILE__": evdev driver version %i.%i.%i", version >> 16, (version >> 8) & 0xff, version & 0xff); if(ioctl(u->fd, EVIOCGID, &input_id)) { - pa_log(__FILE__": EVIOCGID failed: %s", strerror(errno)); + pa_log(__FILE__": EVIOCGID failed: %s", pa_cstrerror(errno)); goto fail; } @@ -204,7 +205,7 @@ int pa__init(pa_core *c, pa_module*m) { memset(name, 0, sizeof(name)); if(ioctl(u->fd, EVIOCGNAME(sizeof(name)), name) < 0) { - pa_log(__FILE__": EVIOCGNAME failed: %s", strerror(errno)); + pa_log(__FILE__": EVIOCGNAME failed: %s", pa_cstrerror(errno)); goto fail; } @@ -212,7 +213,7 @@ int pa__init(pa_core *c, pa_module*m) { memset(evtype_bitmask, 0, sizeof(evtype_bitmask)); if (ioctl(u->fd, EVIOCGBIT(0, EV_MAX), evtype_bitmask) < 0) { - pa_log(__FILE__": EVIOCGBIT failed: %s", strerror(errno)); + pa_log(__FILE__": EVIOCGBIT failed: %s", pa_cstrerror(errno)); goto fail; } diff --git a/src/modules/module-oss-mmap.c b/src/modules/module-oss-mmap.c index a1b40389..dac7d7f3 100644 --- a/src/modules/module-oss-mmap.c +++ b/src/modules/module-oss-mmap.c @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -152,7 +153,7 @@ static void do_write(struct userdata *u) { update_usage(u); if (ioctl(u->fd, SNDCTL_DSP_GETOPTR, &info) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETOPTR: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETOPTR: %s", pa_cstrerror(errno)); return; } @@ -215,7 +216,7 @@ static void do_read(struct userdata *u) { update_usage(u); if (ioctl(u->fd, SNDCTL_DSP_GETIPTR, &info) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETIPTR: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETIPTR: %s", pa_cstrerror(errno)); return; } @@ -246,7 +247,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) { assert(s && u); if (ioctl(u->fd, SNDCTL_DSP_GETOPTR, &info) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETOPTR: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETOPTR: %s", pa_cstrerror(errno)); return 0; } @@ -272,7 +273,7 @@ static pa_usec_t source_get_latency_cb(pa_source *s) { assert(s && u); if (ioctl(u->fd, SNDCTL_DSP_GETIPTR, &info) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETIPTR: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETIPTR: %s", pa_cstrerror(errno)); return 0; } @@ -295,7 +296,7 @@ static int sink_get_hw_volume(pa_sink *s) { struct userdata *u = s->userdata; if (pa_oss_get_pcm_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) { - pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", pa_cstrerror(errno)); s->get_hw_volume = NULL; return -1; } @@ -307,7 +308,7 @@ static int sink_set_hw_volume(pa_sink *s) { struct userdata *u = s->userdata; if (pa_oss_set_pcm_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) { - pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", pa_cstrerror(errno)); s->set_hw_volume = NULL; return -1; } @@ -319,7 +320,7 @@ static int source_get_hw_volume(pa_source *s) { struct userdata *u = s->userdata; if (pa_oss_get_input_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) { - pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", pa_cstrerror(errno)); s->get_hw_volume = NULL; return -1; } @@ -331,7 +332,7 @@ static int source_set_hw_volume(pa_source *s) { struct userdata *u = s->userdata; if (pa_oss_set_input_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) { - pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", pa_cstrerror(errno)); s->set_hw_volume = NULL; return -1; } @@ -413,7 +414,7 @@ int pa__init(pa_core *c, pa_module*m) { if (mode != O_WRONLY) { if (ioctl(u->fd, SNDCTL_DSP_GETISPACE, &info) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETISPACE: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETISPACE: %s", pa_cstrerror(errno)); goto fail; } @@ -425,7 +426,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log(__FILE__": mmap failed for input. Changing to O_WRONLY mode."); mode = O_WRONLY; } else { - pa_log(__FILE__": mmap(): %s", strerror(errno)); + pa_log(__FILE__": mmap(): %s", pa_cstrerror(errno)); goto fail; } } else { @@ -452,7 +453,7 @@ int pa__init(pa_core *c, pa_module*m) { if (mode != O_RDONLY) { if (ioctl(u->fd, SNDCTL_DSP_GETOSPACE, &info) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETOSPACE: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETOSPACE: %s", pa_cstrerror(errno)); goto fail; } @@ -464,7 +465,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_log(__FILE__": mmap filed for output. Changing to O_RDONLY mode."); mode = O_RDONLY; } else { - pa_log(__FILE__": mmap(): %s", strerror(errno)); + pa_log(__FILE__": mmap(): %s", pa_cstrerror(errno)); goto fail; } } else { @@ -492,12 +493,12 @@ int pa__init(pa_core *c, pa_module*m) { zero = 0; if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &zero) < 0) { - pa_log(__FILE__": SNDCTL_DSP_SETTRIGGER: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno)); goto fail; } if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) < 0) { - pa_log(__FILE__": SNDCTL_DSP_SETTRIGGER: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno)); goto fail; } diff --git a/src/modules/module-oss.c b/src/modules/module-oss.c index 9233420d..8e217855 100644 --- a/src/modules/module-oss.c +++ b/src/modules/module-oss.c @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -146,7 +147,7 @@ static void do_write(struct userdata *u) { assert(memchunk->length); if ((r = pa_iochannel_write(u->io, (uint8_t*) memchunk->memblock->data + memchunk->index, memchunk->length)) < 0) { - pa_log(__FILE__": write() failed: %s", strerror(errno)); + pa_log(__FILE__": write() failed: %s", pa_cstrerror(errno)); break; } @@ -199,7 +200,7 @@ static void do_read(struct userdata *u) { if ((r = pa_iochannel_read(u->io, memchunk.memblock->data, memchunk.memblock->length)) < 0) { pa_memblock_unref(memchunk.memblock); if (errno != EAGAIN) - pa_log(__FILE__": read() failed: %s", strerror(errno)); + pa_log(__FILE__": read() failed: %s", pa_cstrerror(errno)); break; } @@ -234,7 +235,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) { assert(s && u && u->sink); if (ioctl(u->fd, SNDCTL_DSP_GETODELAY, &arg) < 0) { - pa_log_info(__FILE__": device doesn't support SNDCTL_DSP_GETODELAY: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support SNDCTL_DSP_GETODELAY: %s", pa_cstrerror(errno)); s->get_latency = NULL; return 0; } @@ -270,7 +271,7 @@ static int sink_get_hw_volume(pa_sink *s) { struct userdata *u = s->userdata; if (pa_oss_get_pcm_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) { - pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", pa_cstrerror(errno)); s->get_hw_volume = NULL; return -1; } @@ -282,7 +283,7 @@ static int sink_set_hw_volume(pa_sink *s) { struct userdata *u = s->userdata; if (pa_oss_set_pcm_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) { - pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", pa_cstrerror(errno)); s->set_hw_volume = NULL; return -1; } @@ -294,7 +295,7 @@ static int source_get_hw_volume(pa_source *s) { struct userdata *u = s->userdata; if (pa_oss_get_input_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) { - pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", pa_cstrerror(errno)); s->get_hw_volume = NULL; return -1; } @@ -306,7 +307,7 @@ static int source_set_hw_volume(pa_source *s) { struct userdata *u = s->userdata; if (pa_oss_set_input_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) { - pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", strerror(errno)); + pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", pa_cstrerror(errno)); s->set_hw_volume = NULL; return -1; } @@ -380,7 +381,7 @@ int pa__init(pa_core *c, pa_module*m) { goto fail; if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &frag_size) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETBLKSIZE: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETBLKSIZE: %s", pa_cstrerror(errno)); goto fail; } assert(frag_size); diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c index 6492ba6a..f0569ce9 100644 --- a/src/modules/module-pipe-sink.c +++ b/src/modules/module-pipe-sink.c @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -99,7 +100,7 @@ static void do_write(struct userdata *u) { assert(u->memchunk.memblock && u->memchunk.length); if ((r = pa_iochannel_write(u->io, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length)) < 0) { - pa_log(__FILE__": write() failed: %s", strerror(errno)); + pa_log(__FILE__": write(): %s", pa_cstrerror(errno)); return; } @@ -163,14 +164,14 @@ int pa__init(pa_core *c, pa_module*m) { mkfifo(p = pa_modargs_get_value(ma, "file", DEFAULT_FIFO_NAME), 0777); if ((fd = open(p, O_RDWR)) < 0) { - pa_log(__FILE__": open('%s'): %s", p, strerror(errno)); + pa_log(__FILE__": open('%s'): %s", p, pa_cstrerror(errno)); goto fail; } pa_fd_set_cloexec(fd, 1); if (fstat(fd, &st) < 0) { - pa_log(__FILE__": fstat('%s'): %s", p, strerror(errno)); + pa_log(__FILE__": fstat('%s'): %s", p, pa_cstrerror(errno)); goto fail; } diff --git a/src/modules/module-pipe-source.c b/src/modules/module-pipe-source.c index 9f755440..77212ce5 100644 --- a/src/modules/module-pipe-source.c +++ b/src/modules/module-pipe-source.c @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -96,7 +97,7 @@ static void do_read(struct userdata *u) { assert(u->chunk.memblock && u->chunk.memblock->length > u->chunk.index); if ((r = pa_iochannel_read(u->io, (uint8_t*) u->chunk.memblock->data + u->chunk.index, u->chunk.memblock->length - u->chunk.index)) <= 0) { - pa_log(__FILE__": read() failed: %s", strerror(errno)); + pa_log(__FILE__": read(): %s", pa_cstrerror(errno)); return; } @@ -141,14 +142,14 @@ int pa__init(pa_core *c, pa_module*m) { mkfifo(p = pa_modargs_get_value(ma, "file", DEFAULT_FIFO_NAME), 0777); if ((fd = open(p, O_RDWR)) < 0) { - pa_log(__FILE__": open('%s'): %s", p, strerror(errno)); + pa_log(__FILE__": open('%s'): %s", p, pa_cstrerror(errno)); goto fail; } pa_fd_set_cloexec(fd, 1); if (fstat(fd, &st) < 0) { - pa_log(__FILE__": fstat('%s'): %s", p, strerror(errno)); + pa_log(__FILE__": fstat('%s'): %s", p, pa_cstrerror(errno)); goto fail; } diff --git a/src/modules/module-protocol-stub.c b/src/modules/module-protocol-stub.c index cfe661a3..8eba352b 100644 --- a/src/modules/module-protocol-stub.c +++ b/src/modules/module-protocol-stub.c @@ -42,6 +42,7 @@ #include "../polypcore/winsock.h" +#include #include #include @@ -250,7 +251,7 @@ int pa__init(pa_core *c, pa_module*m) { } if ((r = pa_unix_socket_remove_stale(tmp)) < 0) { - pa_log(__FILE__": Failed to remove stale UNIX socket '%s': %s", tmp, strerror(errno)); + pa_log(__FILE__": Failed to remove stale UNIX socket '%s': %s", tmp, pa_cstrerror(errno)); goto fail; } @@ -328,7 +329,7 @@ void pa__done(pa_core *c, pa_module*m) { if ((p = pa_parent_dir(u->socket_path))) { if (rmdir(p) < 0 && errno != ENOENT && errno != ENOTEMPTY) - pa_log(__FILE__": Failed to remove %s: %s.", u->socket_path, strerror(errno)); + pa_log(__FILE__": Failed to remove %s: %s.", u->socket_path, pa_cstrerror(errno)); pa_xfree(p); } diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c index 77eb4e49..8670bb35 100644 --- a/src/modules/module-solaris.c +++ b/src/modules/module-solaris.c @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -168,7 +169,7 @@ static void do_write(struct userdata *u) { } if ((r = pa_iochannel_write(u->io, (uint8_t*) memchunk->memblock->data + memchunk->index, len)) < 0) { - pa_log(__FILE__": write() failed: %s", strerror(errno)); + pa_log(__FILE__": write() failed: %s", pa_cstrerror(errno)); return; } @@ -206,7 +207,7 @@ static void do_read(struct userdata *u) { if ((r = pa_iochannel_read(u->io, memchunk.memblock->data, memchunk.memblock->length)) < 0) { pa_memblock_unref(memchunk.memblock); if (errno != EAGAIN) - pa_log(__FILE__": read() failed: %s", strerror(errno)); + pa_log(__FILE__": read() failed: %s", pa_cstrerror(errno)); return; } @@ -334,7 +335,7 @@ static int sink_set_hw_volume_cb(pa_sink *s) { if (errno == EINVAL) pa_log(__FILE__": AUDIO_SETINFO: Unsupported volume."); else - pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno)); + pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno)); return -1; } @@ -363,7 +364,7 @@ static int sink_set_hw_mute_cb(pa_sink *s) { info.output_muted = !!s->hw_muted; if (ioctl(u->fd, AUDIO_SETINFO, &info) < 0) { - pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno)); + pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno)); return -1; } @@ -397,7 +398,7 @@ static int source_set_hw_volume_cb(pa_source *s) { if (errno == EINVAL) pa_log(__FILE__": AUDIO_SETINFO: Unsupported volume."); else - pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno)); + pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno)); return -1; } @@ -463,7 +464,7 @@ static int pa_solaris_auto_format(int fd, int mode, pa_sample_spec *ss) { if (errno == EINVAL) pa_log(__FILE__": AUDIO_SETINFO: Unsupported sample format."); else - pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno)); + pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno)); return -1; } @@ -481,7 +482,7 @@ static int pa_solaris_set_buffer(int fd, int buffer_size) { if (errno == EINVAL) pa_log(__FILE__": AUDIO_SETINFO: Unsupported buffer size."); else - pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno)); + pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno)); return -1; } diff --git a/src/modules/module-volume-restore.c b/src/modules/module-volume-restore.c index e74567bc..796e43a3 100644 --- a/src/modules/module-volume-restore.c +++ b/src/modules/module-volume-restore.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -124,7 +125,7 @@ static int load_rules(struct userdata *u) { pa_log_info(__FILE__": starting with empty ruleset."); ret = 0; } else - pa_log(__FILE__": failed to open file '%s': %s", u->table_file, strerror(errno)); + pa_log(__FILE__": failed to open file '%s': %s", u->table_file, pa_cstrerror(errno)); goto finish; } @@ -198,7 +199,7 @@ static int save_rules(struct userdata *u) { pa_open_config_file(NULL, DEFAULT_VOLUME_TABLE_FILE, NULL, &u->table_file, "w"); if (!f) { - pa_log(__FILE__": failed to open file '%s': %s", u->table_file, strerror(errno)); + pa_log(__FILE__": failed to open file '%s': %s", u->table_file, pa_cstrerror(errno)); goto finish; } diff --git a/src/modules/oss-util.c b/src/modules/oss-util.c index a84276f1..027921c5 100644 --- a/src/modules/oss-util.c +++ b/src/modules/oss-util.c @@ -34,6 +34,8 @@ #include #include +#include + #include #include @@ -51,7 +53,7 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) { tcaps = pcaps ? pcaps : &dcaps; if (ioctl(fd, SNDCTL_DSP_GETCAPS, tcaps) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno)); goto fail; } @@ -65,13 +67,13 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) { if ((fd = open(device, (*mode = O_WRONLY)|O_NDELAY)) < 0) { if ((fd = open(device, (*mode = O_RDONLY)|O_NDELAY)) < 0) { - pa_log(__FILE__": open('%s'): %s", device, strerror(errno)); + pa_log(__FILE__": open('%s'): %s", device, pa_cstrerror(errno)); goto fail; } } } else { if ((fd = open(device, *mode|O_NDELAY)) < 0) { - pa_log(__FILE__": open('%s'): %s", device, strerror(errno)); + pa_log(__FILE__": open('%s'): %s", device, pa_cstrerror(errno)); goto fail; } } @@ -80,7 +82,7 @@ success: if (pcaps) { if (ioctl(fd, SNDCTL_DSP_GETCAPS, pcaps) < 0) { - pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno)); goto fail; } } @@ -118,7 +120,7 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) { if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != f) { format = AFMT_U8; if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != AFMT_U8) { - pa_log(__FILE__": SNDCTL_DSP_SETFMT: %s", format != AFMT_U8 ? "No supported sample format" : strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_SETFMT: %s", format != AFMT_U8 ? "No supported sample format" : pa_cstrerror(errno)); return -1; } else ss->format = PA_SAMPLE_U8; @@ -130,7 +132,7 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) { channels = ss->channels; if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) < 0) { - pa_log(__FILE__": SNDCTL_DSP_CHANNELS: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_CHANNELS: %s", pa_cstrerror(errno)); return -1; } assert(channels); @@ -138,7 +140,7 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) { speed = ss->rate; if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) < 0) { - pa_log(__FILE__": SNDCTL_DSP_SPEED: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_SPEED: %s", pa_cstrerror(errno)); return -1; } assert(speed); @@ -164,7 +166,7 @@ int pa_oss_set_fragments(int fd, int nfrags, int frag_size) { arg = ((int) nfrags << 16) | simple_log2(frag_size); if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) { - pa_log(__FILE__": SNDCTL_DSP_SETFRAGMENT: %s", strerror(errno)); + pa_log(__FILE__": SNDCTL_DSP_SETFRAGMENT: %s", pa_cstrerror(errno)); return -1; } @@ -253,7 +255,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) { !(f = fopen("/proc/asound/oss/sndstat", "r"))) { if (errno != ENOENT) - pa_log_warn(__FILE__": failed to open OSS sndstat device: %s", strerror(errno)); + pa_log_warn(__FILE__": failed to open OSS sndstat device: %s", pa_cstrerror(errno)); return -1; } diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c index 56fc91ef..8d9b33c2 100644 --- a/src/modules/rtp/module-rtp-recv.c +++ b/src/modules/rtp/module-rtp-recv.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -216,13 +217,13 @@ static int mcast_socket(const struct sockaddr* sa, socklen_t salen) { af = sa->sa_family; if ((fd = socket(af, SOCK_DGRAM, 0)) < 0) { - pa_log(__FILE__": Failed to create socket: %s", strerror(errno)); + pa_log(__FILE__": Failed to create socket: %s", pa_cstrerror(errno)); goto fail; } one = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0) { - pa_log(__FILE__": SO_REUSEADDR failed: %s", strerror(errno)); + pa_log(__FILE__": SO_REUSEADDR failed: %s", pa_cstrerror(errno)); goto fail; } @@ -239,12 +240,12 @@ static int mcast_socket(const struct sockaddr* sa, socklen_t salen) { } if (r < 0) { - pa_log_info(__FILE__": Joining mcast group failed: %s", strerror(errno)); + pa_log_info(__FILE__": Joining mcast group failed: %s", pa_cstrerror(errno)); goto fail; } if (bind(fd, sa, salen) < 0) { - pa_log(__FILE__": bind() failed: %s", strerror(errno)); + pa_log(__FILE__": bind() failed: %s", pa_cstrerror(errno)); goto fail; } diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c index 1372414c..c8b3899a 100644 --- a/src/modules/rtp/module-rtp-send.c +++ b/src/modules/rtp/module-rtp-send.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -238,28 +239,28 @@ int pa__init(pa_core *c, pa_module*m) { } if ((fd = socket(af, SOCK_DGRAM, 0)) < 0) { - pa_log(__FILE__": socket() failed: %s", strerror(errno)); + pa_log(__FILE__": socket() failed: %s", pa_cstrerror(errno)); goto fail; } if (connect(fd, af == AF_INET ? (struct sockaddr*) &sa4 : (struct sockaddr*) &sa6, af == AF_INET ? sizeof(sa4) : sizeof(sa6)) < 0) { - pa_log(__FILE__": connect() failed: %s", strerror(errno)); + pa_log(__FILE__": connect() failed: %s", pa_cstrerror(errno)); goto fail; } if ((sap_fd = socket(af, SOCK_DGRAM, 0)) < 0) { - pa_log(__FILE__": socket() failed: %s", strerror(errno)); + pa_log(__FILE__": socket() failed: %s", pa_cstrerror(errno)); goto fail; } if (connect(sap_fd, af == AF_INET ? (struct sockaddr*) &sap_sa4 : (struct sockaddr*) &sap_sa6, af == AF_INET ? sizeof(sap_sa4) : sizeof(sap_sa6)) < 0) { - pa_log(__FILE__": connect() failed: %s", strerror(errno)); + pa_log(__FILE__": connect() failed: %s", pa_cstrerror(errno)); goto fail; } if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) < 0 || setsockopt(sap_fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) < 0) { - pa_log(__FILE__": IP_MULTICAST_LOOP failed: %s", strerror(errno)); + pa_log(__FILE__": IP_MULTICAST_LOOP failed: %s", pa_cstrerror(errno)); goto fail; } diff --git a/src/modules/rtp/rtp.c b/src/modules/rtp/rtp.c index 23e84eb3..012d6578 100644 --- a/src/modules/rtp/rtp.c +++ b/src/modules/rtp/rtp.c @@ -36,6 +36,8 @@ #include #endif +#include + #include #include "rtp.h" @@ -124,7 +126,7 @@ int pa_rtp_send(pa_rtp_context *c, size_t size, pa_memblockq *q) { if (k < 0) { if (errno != EAGAIN) /* If the queue is full, just ignore it */ - pa_log(__FILE__": sendmsg() failed: %s", strerror(errno)); + pa_log(__FILE__": sendmsg() failed: %s", pa_cstrerror(errno)); return -1; } @@ -162,7 +164,7 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_memblock_stat *st) { chunk->memblock = NULL; if (ioctl(c->fd, FIONREAD, &size) < 0) { - pa_log(__FILE__": FIONREAD failed: %s", strerror(errno)); + pa_log(__FILE__": FIONREAD failed: %s", pa_cstrerror(errno)); goto fail; } @@ -183,7 +185,7 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_memblock_stat *st) { m.msg_flags = 0; if ((r = recvmsg(c->fd, &m, 0)) != size) { - pa_log(__FILE__": recvmsg() failed: %s", r < 0 ? strerror(errno) : "size mismatch"); + pa_log(__FILE__": recvmsg() failed: %s", r < 0 ? pa_cstrerror(errno) : "size mismatch"); goto fail; } diff --git a/src/modules/rtp/sap.c b/src/modules/rtp/sap.c index 5b8f31fb..238ee420 100644 --- a/src/modules/rtp/sap.c +++ b/src/modules/rtp/sap.c @@ -38,6 +38,7 @@ #include #endif +#include #include #include @@ -77,7 +78,7 @@ int pa_sap_send(pa_sap_context *c, int goodbye) { int k; if (getsockname(c->fd, sa, &salen) < 0) { - pa_log("getsockname() failed: %s\n", strerror(errno)); + pa_log("getsockname() failed: %s\n", pa_cstrerror(errno)); return -1; } @@ -109,7 +110,7 @@ int pa_sap_send(pa_sap_context *c, int goodbye) { m.msg_flags = 0; if ((k = sendmsg(c->fd, &m, MSG_DONTWAIT)) < 0) - pa_log("sendmsg() failed: %s\n", strerror(errno)); + pa_log("sendmsg() failed: %s\n", pa_cstrerror(errno)); return k; } @@ -136,7 +137,7 @@ int pa_sap_recv(pa_sap_context *c, int *goodbye) { assert(goodbye); if (ioctl(c->fd, FIONREAD, &size) < 0) { - pa_log(__FILE__": FIONREAD failed: %s", strerror(errno)); + pa_log(__FILE__": FIONREAD failed: %s", pa_cstrerror(errno)); goto fail; } @@ -158,7 +159,7 @@ int pa_sap_recv(pa_sap_context *c, int *goodbye) { m.msg_flags = 0; if ((r = recvmsg(c->fd, &m, 0)) != size) { - pa_log(__FILE__": recvmsg() failed: %s", r < 0 ? strerror(errno) : "size mismatch"); + pa_log(__FILE__": recvmsg() failed: %s", r < 0 ? pa_cstrerror(errno) : "size mismatch"); goto fail; } diff --git a/src/polyp/client-conf.c b/src/polyp/client-conf.c index 1ebcff43..0b3154c8 100644 --- a/src/polyp/client-conf.c +++ b/src/polyp/client-conf.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -123,7 +124,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) { pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn, "r"); if (!f && errno != EINTR) { - pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno)); + pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, pa_cstrerror(errno)); goto finish; } diff --git a/src/polyp/context.c b/src/polyp/context.c index a3b49d4b..eb563819 100644 --- a/src/polyp/context.c +++ b/src/polyp/context.c @@ -47,6 +47,7 @@ #include "../polypcore/winsock.h" +#include #include #include @@ -440,7 +441,7 @@ static int context_connect_spawn(pa_context *c) { pa_context_ref(c); if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { - pa_log(__FILE__": socketpair() failed: %s", strerror(errno)); + pa_log(__FILE__": socketpair(): %s", pa_cstrerror(errno)); pa_context_fail(c, PA_ERR_INTERNAL); goto fail; } @@ -454,7 +455,7 @@ static int context_connect_spawn(pa_context *c) { c->spawn_api.prefork(); if ((pid = fork()) < 0) { - pa_log(__FILE__": fork() failed: %s", strerror(errno)); + pa_log(__FILE__": fork(): %s", pa_cstrerror(errno)); pa_context_fail(c, PA_ERR_INTERNAL); if (c->spawn_api.postfork) @@ -510,7 +511,7 @@ static int context_connect_spawn(pa_context *c) { c->spawn_api.postfork(); if (r < 0) { - pa_log(__FILE__": waitpid() failed: %s", strerror(errno)); + pa_log(__FILE__": waitpid(): %s", pa_cstrerror(errno)); pa_context_fail(c, PA_ERR_INTERNAL); goto fail; } else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { diff --git a/src/polyp/error.c b/src/polyp/error.c index e78d072e..062b6f36 100644 --- a/src/polyp/error.c +++ b/src/polyp/error.c @@ -23,9 +23,23 @@ #include #endif +#include #include #include +#include +#ifdef HAVE_PTHREAD +#include +#endif + +#ifdef HAVE_WINDOWS_H +#include +#endif + +#include +#include + +#include #include #include "error.h" @@ -58,3 +72,79 @@ const char*pa_strerror(int error) { return errortab[error]; } + +#ifdef HAVE_PTHREAD + +static pthread_once_t cstrerror_once = PTHREAD_ONCE_INIT; +static pthread_key_t tlsstr_key; + +static void inittls(void) { + int ret; + + ret = pthread_key_create(&tlsstr_key, pa_xfree); + if (ret) { + fprintf(stderr, __FILE__ ": CRITICAL: Unable to allocate TLS key (%d)\n", errno); + exit(-1); + } +} + +#elif HAVE_WINDOWS_H + +static __declspec(thread) char *tlsstr; + +#else + +/* Unsafe, but we have no choice */ +static char *tlsstr; + +#endif + +char* pa_cstrerror(int errnum) { + const char *origbuf; + +#ifdef HAVE_STRERROR_R + char errbuf[128]; +#endif + +#ifdef HAVE_PTHREAD + char *tlsstr; + + pthread_once(&cstrerror_once, inittls); + + tlsstr = pthread_getspecific(tlsstr_key); +#endif + + if (tlsstr) + pa_xfree(tlsstr); + +#ifdef HAVE_STRERROR_R + +#ifdef __GLIBC__ + origbuf = strerror_r(errnum, errbuf, sizeof(errbuf)); + if (origbuf == NULL) + origbuf = ""; +#else + if (strerror_r(errnum, errbuf, sizeof(errbuf)) == 0) { + origbuf = errbuf; + errbuf[sizeof(errbuf) - 1] = '\0'; + } else + origbuf = ""; +#endif + +#else + /* This might not be thread safe, but we hope for the best */ + origbuf = strerror(errnum); +#endif + + tlsstr = pa_locale_to_utf8(origbuf); + if (!tlsstr) { + fprintf(stderr, "Unable to convert, filtering\n"); + tlsstr = pa_utf8_filter(origbuf); + } + +#ifdef HAVE_PTHREAD + pthread_setspecific(tlsstr_key, tlsstr); +#endif + + return tlsstr; +} diff --git a/src/polyp/error.h b/src/polyp/error.h index 9856c1af..33507bfd 100644 --- a/src/polyp/error.h +++ b/src/polyp/error.h @@ -33,6 +33,12 @@ PA_C_DECL_BEGIN /** Return a human readable error message for the specified numeric error code */ const char* pa_strerror(int error); +/** A wrapper around the standard strerror() function that converts the + * string to UTF-8. The function is thread safe but the returned string is + * only guaranteed to exist until the thread exits or pa_cstrerror() is + * called again from the same thread. */ +char* pa_cstrerror(int errnum); + PA_C_DECL_END #endif diff --git a/src/polyp/mainloop-signal.c b/src/polyp/mainloop-signal.c index c57437b6..c6ad431a 100644 --- a/src/polyp/mainloop-signal.c +++ b/src/polyp/mainloop-signal.c @@ -36,6 +36,7 @@ #include #endif +#include #include #include @@ -89,7 +90,7 @@ static void callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags if (errno == EAGAIN) return; - pa_log(__FILE__": read(): %s", strerror(errno)); + pa_log(__FILE__": read(): %s", pa_cstrerror(errno)); return; } @@ -106,7 +107,7 @@ int pa_signal_init(pa_mainloop_api *a) { assert(!api && a && signal_pipe[0] == -1 && signal_pipe[1] == -1 && !io_event); if (pipe(signal_pipe) < 0) { - pa_log(__FILE__": pipe() failed: %s", strerror(errno)); + pa_log(__FILE__": pipe(): %s", pa_cstrerror(errno)); return -1; } diff --git a/src/polyp/mainloop.c b/src/polyp/mainloop.c index 6b5b3b25..6088fa4b 100644 --- a/src/polyp/mainloop.c +++ b/src/polyp/mainloop.c @@ -44,6 +44,7 @@ #include "../polypcore/pipe.h" #endif +#include #include #include @@ -689,7 +690,7 @@ int pa_mainloop_poll(pa_mainloop *m) { if (errno == EINTR) r = 0; else - pa_log(__FILE__": poll(): %s", strerror(errno)); + pa_log(__FILE__": poll(): %s", pa_cstrerror(errno)); } } diff --git a/src/polyp/util.c b/src/polyp/util.c index ed59a5c6..91054483 100644 --- a/src/polyp/util.c +++ b/src/polyp/util.c @@ -51,6 +51,8 @@ #include "../polypcore/winsock.h" +#include + #include #include @@ -107,7 +109,7 @@ char *pa_get_user_name(char *s, size_t l) { char *pa_get_host_name(char *s, size_t l) { assert(s && l > 0); if (gethostname(s, l) < 0) { - pa_log(__FILE__": gethostname(): %s", strerror(errno)); + pa_log(__FILE__": gethostname(): %s", pa_cstrerror(errno)); return NULL; } s[l-1] = 0; diff --git a/src/polypcore/authkey.c b/src/polypcore/authkey.c index aee54fd4..6b462a23 100644 --- a/src/polypcore/authkey.c +++ b/src/polypcore/authkey.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -53,7 +54,7 @@ static int generate(int fd, void *ret_data, size_t length) { ftruncate(fd, 0); if ((r = pa_loop_write(fd, ret_data, length)) < 0 || (size_t) r != length) { - pa_log(__FILE__": failed to write cookie file: %s", strerror(errno)); + pa_log(__FILE__": failed to write cookie file: %s", pa_cstrerror(errno)); return -1; } @@ -75,7 +76,7 @@ static int load(const char *fn, void *data, size_t length) { if ((fd = open(fn, O_RDWR|O_CREAT|O_BINARY, S_IRUSR|S_IWUSR)) < 0) { if (errno != EACCES || (fd = open(fn, O_RDONLY|O_BINARY)) < 0) { - pa_log(__FILE__": failed to open cookie file '%s': %s", fn, strerror(errno)); + pa_log(__FILE__": failed to open cookie file '%s': %s", fn, pa_cstrerror(errno)); goto finish; } else writable = 0; @@ -84,7 +85,7 @@ static int load(const char *fn, void *data, size_t length) { unlock = pa_lock_fd(fd, 1) >= 0; if ((r = pa_loop_read(fd, data, length)) < 0) { - pa_log(__FILE__": failed to read cookie file '%s': %s", fn, strerror(errno)); + pa_log(__FILE__": failed to read cookie file '%s': %s", fn, pa_cstrerror(errno)); goto finish; } @@ -125,7 +126,7 @@ int pa_authkey_load(const char *path, void *data, size_t length) { if (ret < 0) pa_log(__FILE__": Failed to load authorization key '%s': %s", path, - (ret == -1) ? strerror(errno) : "file corrupt"); + (ret == -1) ? pa_cstrerror(errno) : "file corrupt"); return ret; } @@ -181,14 +182,14 @@ int pa_authkey_save(const char *fn, const void *data, size_t length) { return -2; if ((fd = open(p, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR)) < 0) { - pa_log(__FILE__": failed to open cookie file '%s': %s", fn, strerror(errno)); + pa_log(__FILE__": failed to open cookie file '%s': %s", fn, pa_cstrerror(errno)); goto finish; } unlock = pa_lock_fd(fd, 1) >= 0; if ((r = pa_loop_write(fd, data, length)) < 0 || (size_t) r != length) { - pa_log(__FILE__": failed to read cookie file '%s': %s", fn, strerror(errno)); + pa_log(__FILE__": failed to read cookie file '%s': %s", fn, pa_cstrerror(errno)); goto finish; } diff --git a/src/polypcore/cli-command.c b/src/polypcore/cli-command.c index 3adc9a21..039aa957 100644 --- a/src/polypcore/cli-command.c +++ b/src/polypcore/cli-command.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -900,7 +901,7 @@ int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, int assert(c && fn && buf); if (!(f = fopen(fn, "r"))) { - pa_strbuf_printf(buf, "open('%s') failed: %s\n", fn, strerror(errno)); + pa_strbuf_printf(buf, "open('%s') failed: %s\n", fn, pa_cstrerror(errno)); if (!*fail) ret = 0; goto fail; diff --git a/src/polypcore/conf-parser.c b/src/polypcore/conf-parser.c index bc99b871..4bcb83dd 100644 --- a/src/polypcore/conf-parser.c +++ b/src/polypcore/conf-parser.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -112,7 +113,8 @@ int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void goto finish; } - pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to open configuration file '%s': %s", + filename, pa_cstrerror(errno)); goto finish; } @@ -122,7 +124,8 @@ int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void if (feof(f)) break; - pa_log(__FILE__": WARNING: failed to read configuration file '%s': %s", filename, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to read configuration file '%s': %s", + filename, pa_cstrerror(errno)); goto finish; } diff --git a/src/polypcore/core-scache.c b/src/polypcore/core-scache.c index 5cb38bee..1d60a910 100644 --- a/src/polypcore/core-scache.c +++ b/src/polypcore/core-scache.c @@ -41,6 +41,7 @@ #include #endif +#include #include #include #include @@ -359,7 +360,7 @@ static void add_file(pa_core *c, const char *pathname) { e = pa_path_get_filename(pathname); if (stat(pathname, &st) < 0) { - pa_log(__FILE__": stat('%s') failed: %s", pathname, strerror(errno)); + pa_log(__FILE__": stat('%s'): %s", pathname, pa_cstrerror(errno)); return; } @@ -381,7 +382,7 @@ int pa_scache_add_directory_lazy(pa_core *c, const char *pathname) { /* If that fails, try to open it as shell glob */ if (glob(pathname, GLOB_ERR|GLOB_NOSORT, NULL, &p) < 0) { - pa_log(__FILE__": Failed to open directory: %s", strerror(errno)); + pa_log(__FILE__": failed to open directory '%s': %s", pathname, pa_cstrerror(errno)); return -1; } diff --git a/src/polypcore/core-util.c b/src/polypcore/core-util.c index 36044c81..0e7f77a4 100644 --- a/src/polypcore/core-util.c +++ b/src/polypcore/core-util.c @@ -69,6 +69,7 @@ #include +#include #include #include @@ -301,7 +302,7 @@ void pa_check_signal_is_blocked(int sig) { if (pthread_sigmask(SIG_SETMASK, NULL, &set) < 0) { #endif if (sigprocmask(SIG_SETMASK, NULL, &set) < 0) { - pa_log(__FILE__": sigprocmask() failed: %s", strerror(errno)); + pa_log(__FILE__": sigprocmask(): %s", pa_cstrerror(errno)); return; } #ifdef HAVE_PTHREAD @@ -314,7 +315,7 @@ void pa_check_signal_is_blocked(int sig) { /* Check whether the signal is trapped */ if (sigaction(sig, NULL, &sa) < 0) { - pa_log(__FILE__": sigaction() failed: %s", strerror(errno)); + pa_log(__FILE__": sigaction(): %s", pa_cstrerror(errno)); return; } @@ -396,7 +397,7 @@ void pa_raise_priority(void) { #ifdef HAVE_SYS_RESOURCE_H if (setpriority(PRIO_PROCESS, 0, NICE_LEVEL) < 0) - pa_log_warn(__FILE__": setpriority() failed: %s", strerror(errno)); + pa_log_warn(__FILE__": setpriority(): %s", pa_cstrerror(errno)); else pa_log_info(__FILE__": Successfully gained nice level %i.", NICE_LEVEL); #endif @@ -406,13 +407,13 @@ void pa_raise_priority(void) { struct sched_param sp; if (sched_getparam(0, &sp) < 0) { - pa_log(__FILE__": sched_getparam() failed: %s", strerror(errno)); + pa_log(__FILE__": sched_getparam(): %s", pa_cstrerror(errno)); return; } sp.sched_priority = 1; if (sched_setscheduler(0, SCHED_FIFO, &sp) < 0) { - pa_log_warn(__FILE__": sched_setscheduler() failed: %s", strerror(errno)); + pa_log_warn(__FILE__": sched_setscheduler(): %s", pa_cstrerror(errno)); return; } @@ -563,7 +564,7 @@ static int is_group(gid_t gid, const char *name) { data = pa_xmalloc(n); if (getgrgid_r(gid, &group, data, n, &result) < 0 || !result) { - pa_log(__FILE__ ": getgrgid_r(%u) failed: %s", gid, strerror(errno)); + pa_log(__FILE__": getgrgid_r(%u): %s", gid, pa_cstrerror(errno)); goto finish; } @@ -575,8 +576,8 @@ finish: /* XXX Not thread-safe, but needed on OSes (e.g. FreeBSD 4.X) that do not * support getgrgid_r. */ if ((result = getgrgid(gid)) == NULL) { - pa_log(__FILE__ ": getgrgid(%u) failed: %s", gid, strerror(errno)); - goto finish; + pa_log(__FILE__": getgrgid(%u): %s", gid, pa_cstrerror(errno)); + goto finish; } r = strcmp(name, result->gr_name) == 0; @@ -598,7 +599,7 @@ int pa_own_uid_in_group(const char *name, gid_t *gid) { gids = pa_xmalloc(sizeof(GETGROUPS_T)*n); if ((n = getgroups(n, gids)) < 0) { - pa_log(__FILE__": getgroups() failed: %s", strerror(errno)); + pa_log(__FILE__": getgroups(): %s", pa_cstrerror(errno)); goto finish; } @@ -696,7 +697,8 @@ int pa_lock_fd(int fd, int b) { return 0; } - pa_log(__FILE__": %slock failed: %s", !b ? "un" : "", strerror(errno)); + pa_log(__FILE__": %slock: %s", !b? "un" : "", + pa_cstrerror(errno)); #endif #ifdef OS_IS_WIN32 @@ -730,7 +732,8 @@ int pa_lock_lockfile(const char *fn) { struct stat st; if ((fd = open(fn, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)) < 0) { - pa_log(__FILE__": failed to create lock file '%s': %s", fn, strerror(errno)); + pa_log(__FILE__": failed to create lock file '%s': %s", fn, + pa_cstrerror(errno)); goto fail; } @@ -777,7 +780,8 @@ int pa_unlock_lockfile(const char *fn, int fd) { assert(fn && fd >= 0); if (unlink(fn) < 0) { - pa_log_warn(__FILE__": WARNING: unable to remove lock file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: unable to remove lock file '%s': %s", + fn, pa_cstrerror(errno)); r = -1; } @@ -787,7 +791,8 @@ int pa_unlock_lockfile(const char *fn, int fd) { } if (close(fd) < 0) { - pa_log_warn(__FILE__": WARNING: failed to close lock file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to close lock file '%s': %s", + fn, pa_cstrerror(errno)); r = -1; } diff --git a/src/polypcore/iochannel.c b/src/polypcore/iochannel.c index 10997d62..8af6a36b 100644 --- a/src/polypcore/iochannel.c +++ b/src/polypcore/iochannel.c @@ -38,6 +38,7 @@ #include "winsock.h" +#include #include #include @@ -253,7 +254,7 @@ int pa_iochannel_creds_enable(pa_iochannel *io) { 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", strerror(errno)); + pa_log_error("setsockopt(SOL_SOCKET, SO_PASSCRED): %s", pa_cstrerror(errno)); return -1; } diff --git a/src/polypcore/ioline.c b/src/polypcore/ioline.c index 9bb610fe..2e0a3e1a 100644 --- a/src/polypcore/ioline.c +++ b/src/polypcore/ioline.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -275,7 +276,7 @@ static int do_read(pa_ioline *l) { pa_ioline_puts(l, "\nExiting.\n"); do_write(l); } else if (r < 0) { - pa_log(__FILE__": read() failed: %s", strerror(errno)); + pa_log(__FILE__": read(): %s", pa_cstrerror(errno)); failure(l); return -1; } @@ -297,7 +298,7 @@ static int do_write(pa_ioline *l) { while (!l->dead && pa_iochannel_is_writable(l->io) && l->wbuf_valid_length) { if ((r = pa_iochannel_write(l->io, l->wbuf+l->wbuf_index, l->wbuf_valid_length)) < 0) { - pa_log(__FILE__": write() failed: %s", r < 0 ? strerror(errno) : "EOF"); + pa_log(__FILE__": write(): %s", r < 0 ? pa_cstrerror(errno) : "EOF"); failure(l); return -1; } diff --git a/src/polypcore/log.c b/src/polypcore/log.c index ce9df1a9..6cdffa51 100644 --- a/src/polypcore/log.c +++ b/src/polypcore/log.c @@ -94,6 +94,9 @@ void pa_log_levelv(pa_log_level_t level, const char *format, va_list ap) { text = pa_vsprintf_malloc(format, ap); + if (!pa_utf8_valid(text)) + pa_log_level(level, __FILE__": invalid UTF-8 string following below:"); + for (t = text; t; t = n) { if ((n = strchr(t, '\n'))) { *n = 0; diff --git a/src/polypcore/pid.c b/src/polypcore/pid.c index e98dc97b..b8f53955 100644 --- a/src/polypcore/pid.c +++ b/src/polypcore/pid.c @@ -39,6 +39,7 @@ #include #endif +#include #include #include @@ -56,7 +57,8 @@ static pid_t read_pid(const char *fn, int fd) { assert(fn && fd >= 0); if ((r = pa_loop_read(fd, t, sizeof(t)-1)) < 0) { - pa_log(__FILE__": WARNING: failed to read PID file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to read PID file '%s': %s", + fn, pa_cstrerror(errno)); return (pid_t) -1; } @@ -86,7 +88,8 @@ static int open_pid_file(const char *fn, int mode) { if ((fd = open(fn, mode, S_IRUSR|S_IWUSR)) < 0) { if (mode != O_RDONLY || errno != ENOENT) - pa_log(__FILE__": WARNING: failed to open PID file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to open PID file '%s': %s", + fn, pa_cstrerror(errno)); goto fail; } @@ -95,7 +98,8 @@ static int open_pid_file(const char *fn, int mode) { goto fail; if (fstat(fd, &st) < 0) { - pa_log(__FILE__": Failed to fstat() PID file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to fstat() PID file '%s': %s", + fn, pa_cstrerror(errno)); goto fail; } @@ -107,7 +111,8 @@ static int open_pid_file(const char *fn, int mode) { goto fail; if (close(fd) < 0) { - pa_log(__FILE__": Failed to close file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to close file '%s': %s", + fn, pa_cstrerror(errno)); goto fail; } @@ -164,7 +169,8 @@ int pa_pid_file_create(void) { /* Overwrite the current PID file */ if (lseek(fd, 0, SEEK_SET) == (off_t) -1 || ftruncate(fd, 0) < 0) { - pa_log(__FILE__": failed to truncate PID fil: %s.", strerror(errno)); + pa_log(__FILE__": failed to truncate PID file '%s': %s", + fn, pa_cstrerror(errno)); goto fail; } @@ -198,7 +204,8 @@ int pa_pid_file_remove(void) { pa_runtime_path("pid", fn, sizeof(fn)); if ((fd = open_pid_file(fn, O_RDWR)) < 0) { - pa_log(__FILE__": WARNING: failed to open PID file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to open PID file '%s': %s", + fn, pa_cstrerror(errno)); goto fail; } @@ -211,7 +218,8 @@ int pa_pid_file_remove(void) { } if (ftruncate(fd, 0) < 0) { - pa_log(__FILE__": failed to truncate PID file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to truncate PID file '%s': %s", + fn, pa_cstrerror(errno)); goto fail; } @@ -222,7 +230,8 @@ int pa_pid_file_remove(void) { #endif if (unlink(fn) < 0) { - pa_log(__FILE__": failed to remove PID file '%s': %s", fn, strerror(errno)); + pa_log_warn(__FILE__": WARNING: failed to remove PID file '%s': %s", + fn, pa_cstrerror(errno)); goto fail; } diff --git a/src/polypcore/protocol-esound.c b/src/polypcore/protocol-esound.c index c11bdb21..01a72e84 100644 --- a/src/polypcore/protocol-esound.c +++ b/src/polypcore/protocol-esound.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -812,7 +813,7 @@ static int do_read(struct connection *c) { assert(c->read_data_length < sizeof(c->request)); if ((r = pa_iochannel_read(c->io, ((uint8_t*) &c->request) + c->read_data_length, sizeof(c->request) - c->read_data_length)) <= 0) { - pa_log_debug(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF"); + pa_log_debug(__FILE__": read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF"); return -1; } @@ -860,7 +861,7 @@ static int do_read(struct connection *c) { assert(c->read_data && c->read_data_length < handler->data_length); if ((r = pa_iochannel_read(c->io, (uint8_t*) c->read_data + c->read_data_length, handler->data_length - c->read_data_length)) <= 0) { - pa_log_debug(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF"); + pa_log_debug(__FILE__": read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF"); return -1; } @@ -880,7 +881,7 @@ static int do_read(struct connection *c) { assert(c->scache.memchunk.memblock && c->scache.name && c->scache.memchunk.index < c->scache.memchunk.length); if ((r = pa_iochannel_read(c->io, (uint8_t*) c->scache.memchunk.memblock->data+c->scache.memchunk.index, c->scache.memchunk.length-c->scache.memchunk.index)) <= 0) { - pa_log_debug(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF"); + pa_log_debug(__FILE__": read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF"); return -1; } @@ -935,7 +936,7 @@ static int do_read(struct connection *c) { } if ((r = pa_iochannel_read(c->io, (uint8_t*) c->playback.current_memblock->data+c->playback.memblock_index, l)) <= 0) { - pa_log_debug(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF"); + pa_log_debug(__FILE__": read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF"); return -1; } @@ -965,7 +966,7 @@ static int do_write(struct connection *c) { assert(c->write_data_index < c->write_data_length); if ((r = pa_iochannel_write(c->io, (uint8_t*) c->write_data+c->write_data_index, c->write_data_length-c->write_data_index)) < 0) { - pa_log(__FILE__": write() failed: %s", strerror(errno)); + pa_log(__FILE__": write(): %s", pa_cstrerror(errno)); return -1; } @@ -984,7 +985,7 @@ static int do_write(struct connection *c) { if ((r = pa_iochannel_write(c->io, (uint8_t*) chunk.memblock->data+chunk.index, chunk.length)) < 0) { pa_memblock_unref(chunk.memblock); - pa_log(__FILE__": write(): %s", strerror(errno)); + pa_log(__FILE__": write(): %s", pa_cstrerror(errno)); return -1; } diff --git a/src/polypcore/protocol-simple.c b/src/polypcore/protocol-simple.c index caffd5c9..f15f882a 100644 --- a/src/polypcore/protocol-simple.c +++ b/src/polypcore/protocol-simple.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -133,7 +134,7 @@ static int do_read(struct connection *c) { } if ((r = pa_iochannel_read(c->io, (uint8_t*) c->playback.current_memblock->data+c->playback.memblock_index, l)) <= 0) { - pa_log_debug(__FILE__": read() failed: %s", r == 0 ? "EOF" : strerror(errno)); + pa_log_debug(__FILE__": read(): %s", r == 0 ? "EOF" : pa_cstrerror(errno)); return -1; } @@ -167,7 +168,7 @@ static int do_write(struct connection *c) { if ((r = pa_iochannel_write(c->io, (uint8_t*) chunk.memblock->data+chunk.index, chunk.length)) < 0) { pa_memblock_unref(chunk.memblock); - pa_log(__FILE__": write(): %s", strerror(errno)); + pa_log(__FILE__": write(): %s", pa_cstrerror(errno)); return -1; } diff --git a/src/polypcore/socket-client.c b/src/polypcore/socket-client.c index ec2f9a9e..aa885759 100644 --- a/src/polypcore/socket-client.c +++ b/src/polypcore/socket-client.c @@ -54,6 +54,7 @@ #include "winsock.h" +#include #include #include @@ -139,7 +140,7 @@ static void do_call(pa_socket_client *c) { lerror = sizeof(error); if (getsockopt(c->fd, SOL_SOCKET, SO_ERROR, (void*)&error, &lerror) < 0) { - pa_log(__FILE__": getsockopt(): %s", strerror(errno)); + pa_log(__FILE__": getsockopt(): %s", pa_cstrerror(errno)); goto finish; } @@ -149,7 +150,7 @@ static void do_call(pa_socket_client *c) { } if (error != 0) { - pa_log_debug(__FILE__": connect(): %s", strerror(error)); + pa_log_debug(__FILE__": connect(): %s", pa_cstrerror(errno)); errno = error; goto finish; } @@ -194,7 +195,7 @@ static int do_connect(pa_socket_client *c, const struct sockaddr *sa, socklen_t pa_log_debug(__FILE__": connect(): %d", WSAGetLastError()); #else if (errno != EINPROGRESS) { - pa_log_debug(__FILE__": connect(): %s (%d)", strerror(errno), errno); + pa_log_debug(__FILE__": connect(): %s (%d)", pa_cstrerror(errno), errno); #endif return -1; } @@ -266,7 +267,7 @@ static int sockaddr_prepare(pa_socket_client *c, const struct sockaddr *sa, size } if ((c->fd = socket(sa->sa_family, SOCK_STREAM, 0)) < 0) { - pa_log(__FILE__": socket(): %s", strerror(errno)); + pa_log(__FILE__": socket(): %s", pa_cstrerror(errno)); return -1; } diff --git a/src/polypcore/socket-server.c b/src/polypcore/socket-server.c index 592b6a63..871fac11 100644 --- a/src/polypcore/socket-server.c +++ b/src/polypcore/socket-server.c @@ -64,6 +64,7 @@ #include #include +#include #include #include @@ -94,7 +95,7 @@ static void callback(pa_mainloop_api *mainloop, pa_io_event *e, int fd, PA_GCC_U pa_socket_server_ref(s); if ((nfd = accept(fd, NULL, NULL)) < 0) { - pa_log(__FILE__": accept(): %s", strerror(errno)); + pa_log(__FILE__": accept(): %s", pa_cstrerror(errno)); goto finish; } @@ -173,7 +174,7 @@ pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *file assert(m && filename); if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - pa_log(__FILE__": socket(): %s", strerror(errno)); + pa_log(__FILE__": socket(): %s", pa_cstrerror(errno)); goto fail; } @@ -186,12 +187,12 @@ pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *file pa_socket_low_delay(fd); if (bind(fd, (struct sockaddr*) &sa, SUN_LEN(&sa)) < 0) { - pa_log(__FILE__": bind(): %s", strerror(errno)); + pa_log(__FILE__": bind(): %s", pa_cstrerror(errno)); goto fail; } if (listen(fd, 5) < 0) { - pa_log(__FILE__": listen(): %s", strerror(errno)); + pa_log(__FILE__": listen(): %s", pa_cstrerror(errno)); goto fail; } @@ -227,7 +228,7 @@ pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address assert(m && port); if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { - pa_log(__FILE__": socket(PF_INET): %s", strerror(errno)); + pa_log(__FILE__": socket(PF_INET): %s", pa_cstrerror(errno)); goto fail; } @@ -235,7 +236,7 @@ pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address #ifdef SO_REUSEADDR if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) - pa_log(__FILE__": setsockopt(): %s", strerror(errno)); + pa_log(__FILE__": setsockopt(): %s", pa_cstrerror(errno)); #endif pa_socket_tcp_low_delay(fd); @@ -246,12 +247,12 @@ pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address sa.sin_addr.s_addr = htonl(address); if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { - pa_log(__FILE__": bind(): %s", strerror(errno)); + pa_log(__FILE__": bind(): %s", pa_cstrerror(errno)); goto fail; } if (listen(fd, 5) < 0) { - pa_log(__FILE__": listen(): %s", strerror(errno)); + pa_log(__FILE__": listen(): %s", pa_cstrerror(errno)); goto fail; } @@ -278,7 +279,7 @@ pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t ad assert(m && port); if ((fd = socket(PF_INET6, SOCK_STREAM, 0)) < 0) { - pa_log(__FILE__": socket(PF_INET6): %s", strerror(errno)); + pa_log(__FILE__": socket(PF_INET6): %s", pa_cstrerror(errno)); goto fail; } @@ -286,12 +287,12 @@ pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t ad #ifdef IPV6_V6ONLY if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) - pa_log(__FILE__": setsockopt(IPPROTO_IPV6, IPV6_V6ONLY): %s", strerror(errno)); + pa_log(__FILE__": setsockopt(IPPROTO_IPV6, IPV6_V6ONLY): %s", pa_cstrerror(errno)); #endif #ifdef SO_REUSEADDR if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) - pa_log(__FILE__": setsockopt(SOL_SOCKET, SO_REUSEADDR, 1): %s", strerror(errno)); + pa_log(__FILE__": setsockopt(SOL_SOCKET, SO_REUSEADDR, 1): %s", pa_cstrerror(errno)); #endif pa_socket_tcp_low_delay(fd); @@ -302,12 +303,12 @@ pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t ad memcpy(sa.sin6_addr.s6_addr, address, 16); if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { - pa_log(__FILE__": bind(): %s", strerror(errno)); + pa_log(__FILE__": bind(): %s", pa_cstrerror(errno)); goto fail; } if (listen(fd, 5) < 0) { - pa_log(__FILE__": listen(): %s", strerror(errno)); + pa_log(__FILE__": listen(): %s", pa_cstrerror(errno)); goto fail; } @@ -418,7 +419,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) { socklen_t sa_len = sizeof(sa); if (getsockname(s->fd, (struct sockaddr*) &sa, &sa_len) < 0) { - pa_log(__FILE__": getsockname() failed: %s", strerror(errno)); + pa_log(__FILE__": getsockname(): %s", pa_cstrerror(errno)); return NULL; } @@ -439,7 +440,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) { char ip[INET6_ADDRSTRLEN]; if (!inet_ntop(AF_INET6, &sa.sin6_addr, ip, sizeof(ip))) { - pa_log(__FILE__": inet_ntop() failed: %s", strerror(errno)); + pa_log(__FILE__": inet_ntop(): %s", pa_cstrerror(errno)); return NULL; } @@ -454,7 +455,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) { socklen_t sa_len = sizeof(sa); if (getsockname(s->fd, (struct sockaddr*) &sa, &sa_len) < 0) { - pa_log(__FILE__": getsockname() failed: %s", strerror(errno)); + pa_log(__FILE__": getsockname(): %s", pa_cstrerror(errno)); return NULL; } @@ -474,7 +475,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) { char ip[INET_ADDRSTRLEN]; if (!inet_ntop(AF_INET, &sa.sin_addr, ip, sizeof(ip))) { - pa_log(__FILE__": inet_ntop() failed: %s", strerror(errno)); + pa_log(__FILE__": inet_ntop(): %s", pa_cstrerror(errno)); return NULL; } diff --git a/src/polypcore/socket-util.c b/src/polypcore/socket-util.c index acbb7c1f..06cdc625 100644 --- a/src/polypcore/socket-util.c +++ b/src/polypcore/socket-util.c @@ -59,6 +59,7 @@ #include "winsock.h" +#include #include #include @@ -198,7 +199,7 @@ int pa_unix_socket_is_stale(const char *fn) { int fd = -1, ret = -1; if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - pa_log(__FILE__": socket(): %s", strerror(errno)); + pa_log(__FILE__": socket(): %s", pa_cstrerror(errno)); goto finish; } diff --git a/src/utils/pacmd.c b/src/utils/pacmd.c index 539d205e..351d79da 100644 --- a/src/utils/pacmd.c +++ b/src/utils/pacmd.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -53,7 +54,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { } if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - pa_log(__FILE__": socket(PF_UNIX, SOCK_STREAM, 0): %s", strerror(errno)); + pa_log(__FILE__": socket(PF_UNIX, SOCK_STREAM, 0): %s", pa_cstrerror(errno)); goto fail; } @@ -65,7 +66,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { int r; if ((r = connect(fd, (struct sockaddr*) &sa, sizeof(sa))) < 0 && (errno != ECONNREFUSED && errno != ENOENT)) { - pa_log(__FILE__": connect() failed: %s", strerror(errno)); + pa_log(__FILE__": connect(): %s", pa_cstrerror(errno)); goto fail; } @@ -96,7 +97,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { for (;;) { if (select(FD_SETSIZE, &ifds, &ofds, NULL, NULL) < 0) { - pa_log(__FILE__": select() failed: %s", strerror(errno)); + pa_log(__FILE__": select(): %s", pa_cstrerror(errno)); goto fail; } @@ -108,7 +109,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { if (r == 0) break; - pa_log(__FILE__": read() failed: %s", strerror(errno)); + pa_log(__FILE__": read(): %s", pa_cstrerror(errno)); goto fail; } @@ -124,7 +125,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { if (r == 0) break; - pa_log(__FILE__": read() failed: %s", strerror(errno)); + pa_log(__FILE__": read(): %s", pa_cstrerror(errno)); goto fail; } @@ -137,7 +138,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { assert(obuf_length); if ((r = write(1, obuf + obuf_index, obuf_length)) < 0) { - pa_log(__FILE__": write() failed: %s", strerror(errno)); + pa_log(__FILE__": write(): %s", pa_cstrerror(errno)); goto fail; } @@ -151,7 +152,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { assert(ibuf_length); if ((r = write(fd, ibuf + ibuf_index, ibuf_length)) < 0) { - pa_log(__FILE__": write() failed: %s", strerror(errno)); + pa_log(__FILE__": write(): %s", pa_cstrerror(errno)); goto fail; } -- cgit