From db8330c9e516ac359e199b999c5321c73aaffabf Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 17 Aug 2021 15:09:50 -0700 Subject: [PATCH] libct/nsenter: fix unused-result warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 2bab4a5 resulted in a warning from gcc: nsexec.c: In function ‘write_log’: nsexec.c:171:2: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] 171 | write(logfd, json, ret); | ^~~~~~~~~~~~~~~~~~~~~~~ As there's nothing we can or want to do in case write fails, let's just tell the compiler we're not going to use it. Fixes: 2bab4a5 Signed-off-by: Kir Kolyshkin --- libcontainer/nsenter/nsexec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcontainer/nsenter/nsexec.c b/libcontainer/nsenter/nsexec.c index 9b43934d8d2..23861a84681 100644 --- a/libcontainer/nsenter/nsexec.c +++ b/libcontainer/nsenter/nsexec.c @@ -168,7 +168,10 @@ static void write_log(const char *level, const char *format, ...) goto out; } - write(logfd, json, ret); + /* This logging is on a best-effort basis. In case of a short or failed + * write there is nothing we can do, so just ignore write() errors. + */ + ssize_t __attribute__((unused)) __res = write(logfd, json, ret); out: free(message);