Skip to content

Commit db8330c

Browse files
committed
libct/nsenter: fix unused-result warning
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 <[email protected]>
1 parent e53e97a commit db8330c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libcontainer/nsenter/nsexec.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ static void write_log(const char *level, const char *format, ...)
168168
goto out;
169169
}
170170

171-
write(logfd, json, ret);
171+
/* This logging is on a best-effort basis. In case of a short or failed
172+
* write there is nothing we can do, so just ignore write() errors.
173+
*/
174+
ssize_t __attribute__((unused)) __res = write(logfd, json, ret);
172175

173176
out:
174177
free(message);

0 commit comments

Comments
 (0)