diff --git a/pipewire/client/context.c b/pipewire/client/context.c index e453c5912..5209b164f 100644 --- a/pipewire/client/context.c +++ b/pipewire/client/context.c @@ -83,7 +83,10 @@ context_set_state(struct pw_context *context, enum pw_context_state state, const va_list varargs; va_start(varargs, fmt); - vasprintf(&context->error, fmt, varargs); + if (vasprintf(&context->error, fmt, varargs) < 0) { + pw_log_debug("context %p: error formating message: %m", context); + context->error = NULL; + } va_end(varargs); } else { context->error = NULL; diff --git a/pipewire/client/extension.c b/pipewire/client/extension.c index 1025b4a2b..9fb773165 100644 --- a/pipewire/client/extension.c +++ b/pipewire/client/extension.c @@ -63,8 +63,7 @@ struct pw_extension *pw_extension_load(struct pw_context *context, pw_log_debug("PIPEWIRE_MODULE_DIR set to: %s", module_dir); - asprintf(&filename, "%s/%s.so", module_dir, name); - if (filename == NULL) + if (asprintf(&filename, "%s/%s.so", module_dir, name) < 0) goto no_filename; pw_log_debug("trying to load extension: %s (%s)", name, filename); @@ -101,18 +100,22 @@ struct pw_extension *pw_extension_load(struct pw_context *context, return this; no_filename: - pw_log_error("No memory"); + pw_log_error("Can't create filename: %m"); return NULL; open_failed: pw_log_error("Failed to open module: \"%s\" %s", filename, dlerror()); free(filename); return NULL; - no_mem: no_pw_extension: pw_log_error("\"%s\" is not a pipewire extension", name); dlclose(hnd); free(filename); return NULL; + no_mem: + pw_log_error("no memory"); + dlclose(hnd); + free(filename); + return NULL; init_failed: pw_log_error("\"%s\" failed to initialize", name); pw_extension_destroy(this); diff --git a/pipewire/client/pipewire.c b/pipewire/client/pipewire.c index 8f33b26cd..cde188a22 100644 --- a/pipewire/client/pipewire.c +++ b/pipewire/client/pipewire.c @@ -47,7 +47,8 @@ open_support(const char *path, { char *filename; - asprintf(&filename, "%s/%s.so", path, lib); + if (asprintf(&filename, "%s/%s.so", path, lib) < 0) + goto no_filename; if ((info->hnd = dlopen(filename, RTLD_NOW)) == NULL) { fprintf(stderr, "can't load %s: %s\n", filename, dlerror()); @@ -60,6 +61,8 @@ open_support(const char *path, free(filename); return true; + no_filename: + return false; no_symbol: dlclose(info->hnd); open_failed: @@ -282,7 +285,8 @@ char *pw_get_client_name(void) else if ((cc = pw_get_prgname())) return strdup(cc); else { - asprintf(&c, "pipewire-pid-%zd", (size_t) getpid()); + if (asprintf(&c, "pipewire-pid-%zd", (size_t) getpid()) < 0) + return NULL; return c; } } diff --git a/pipewire/modules/module-client-node/client-node.c b/pipewire/modules/module-client-node/client-node.c index 2d8f4da33..107f001a2 100644 --- a/pipewire/modules/module-client-node/client-node.c +++ b/pipewire/modules/module-client-node/client-node.c @@ -154,7 +154,9 @@ static int spa_proxy_node_set_props(struct spa_node *node, const struct spa_prop static inline void do_flush(struct proxy *this) { uint64_t cmd = 1; - write(this->writefd, &cmd, 8); + if (write(this->writefd, &cmd, 8) != 8) + spa_log_warn(this->log, "proxy %p: error writing event: %s", this, strerror(errno)); + } static inline void send_need_input(struct proxy *this) @@ -967,7 +969,9 @@ static void proxy_on_data_fd_events(struct spa_source *source) struct spa_event event; uint64_t cmd; - read(this->data_source.fd, &cmd, 8); + if (read(this->data_source.fd, &cmd, 8) != 8) + spa_log_warn(this->log, "proxy %p: error reading event: %s", + this, strerror(errno)); while (pw_transport_next_event(impl->transport, &event) == SPA_RESULT_OK) { struct spa_event *ev = alloca(SPA_POD_SIZE(&event)); diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index 032a2f0a4..c8a6e5cd5 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -481,7 +481,8 @@ static void alsa_on_playback_timeout_event(struct spa_source *source) snd_pcm_status_t *status; snd_htimestamp_t htstamp; - read(state->timerfd, &exp, sizeof(uint64_t)); + if (read(state->timerfd, &exp, sizeof(uint64_t)) != sizeof(uint64_t)) + spa_log_warn(state->log, "error reading timerfd: %s", strerror(errno)); snd_pcm_status_alloca(&status); @@ -566,7 +567,8 @@ static void alsa_on_capture_timeout_event(struct spa_source *source) snd_pcm_status_t *status; snd_htimestamp_t htstamp; - read(state->timerfd, &exp, sizeof(uint64_t)); + if (read(state->timerfd, &exp, sizeof(uint64_t)) != sizeof(uint64_t)) + spa_log_warn(state->log, "error reading timerfd: %s", strerror(errno)); snd_pcm_status_alloca(&status); diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 09973eed3..96c048f5b 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -94,7 +94,8 @@ impl_log_logv(struct spa_log *log, index & impl->trace_rb.mask, location, size); spa_ringbuffer_write_update(&impl->trace_rb, index + size); - write(impl->source.fd, &count, sizeof(uint64_t)); + if (write(impl->source.fd, &count, sizeof(uint64_t)) != sizeof(uint64_t)) + fprintf(stderr, "error signaling eventfd: %s\n", strerror(errno)); } else fputs(location, stderr); }