From 27a47a96ed75db8a6dcbb7e6181ca5a663e63aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 May 2019 11:28:25 +0200 Subject: [PATCH] module/mpd: check return value of write() Fixes building with -D_FORTIFY_SOURCE=2 --- modules/mpd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/mpd.c b/modules/mpd.c index 43420e6..d1e88f4 100644 --- a/modules/mpd.c +++ b/modules/mpd.c @@ -65,10 +65,15 @@ destroy(struct module *mod) struct private *m = mod->private; if (m->refresh_thread_id != 0) { assert(m->refresh_abort_fd != -1); - write(m->refresh_abort_fd, &(uint64_t){1}, sizeof(uint64_t)); + if (write(m->refresh_abort_fd, &(uint64_t){1}, sizeof(uint64_t)) + != sizeof(uint64_t)) + { + LOG_ERRNO("failed to signal abort to refresher thread"); + } else{ + int res; + thrd_join(m->refresh_thread_id, &res); + } - int res; - thrd_join(m->refresh_thread_id, &res); close(m->refresh_abort_fd); }; @@ -521,7 +526,12 @@ refresh_in(struct module *mod, long milli_seconds) /* Signal abort to thread */ assert(m->refresh_abort_fd != -1); - write(m->refresh_abort_fd, &(uint64_t){1}, sizeof(uint64_t)); + if (write(m->refresh_abort_fd, &(uint64_t){1}, sizeof(uint64_t)) + != sizeof(uint64_t)) + { + LOG_ERRNO("failed to signal abort to refresher thread"); + return false; + } /* Wait for it to finish */ int res;