From 101194ebf6834198300032f6fb438f2c4cdf0401 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 10 Dec 2019 18:59:06 +0100 Subject: executor: check pwrite return values again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build with some gcc's fails: In file included from executor/executor.cc:133:0: executor/common_linux.h: In function ‘long int syz_read_part_table(long unsigned int, long unsigned int, long int)’: executor/common.h:117:15: error: ignoring return value of ‘ssize_t pwrite(int, const void*, size_t, __off_t)’, declared with attribute warn_unused_result [-Werror=unused-result] __VA_ARGS__; \ ^ executor/common_linux.h:1279:3: note: in expansion of macro ‘NONFAILING’ NONFAILING(pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset)); ^ executor/common_linux.h: In function ‘long int syz_mount_image(long int, long int, long unsigned int, long unsigned int, long int, long int, long int)’: executor/common.h:117:15: error: ignoring return value of ‘ssize_t pwrite(int, const void*, size_t, __off_t)’, declared with attribute warn_unused_result [-Werror=unused-result] __VA_ARGS__; \ ^ executor/common_linux.h:1364:3: note: in expansion of macro ‘NONFAILING’ NONFAILING(pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset)); ^ cc1plus: all warnings being treated as errors --- executor/common_linux.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'executor') diff --git a/executor/common_linux.h b/executor/common_linux.h index 74ffa0847..4ad991fc4 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -1276,7 +1276,11 @@ static long syz_read_part_table(volatile unsigned long size, volatile unsigned l } for (i = 0; i < nsegs; i++) { struct fs_image_segment* segs = (struct fs_image_segment*)segments; - NONFAILING(pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset)); + int res1 = 0; + NONFAILING(res1 = pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset)); + if (res1 < 0) { + debug("syz_read_part_table: pwrite[%u] failed: %d\n", (int)i, errno); + } } snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); loopfd = open(loopname, O_RDWR); @@ -1361,7 +1365,11 @@ static long syz_mount_image(volatile long fsarg, volatile long dir, volatile uns } for (i = 0; i < nsegs; i++) { struct fs_image_segment* segs = (struct fs_image_segment*)segments; - NONFAILING(pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset)); + int res1 = 0; + NONFAILING(res1 = pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset)); + if (res1 < 0) { + debug("syz_mount_image: pwrite[%u] failed: %d\n", (int)i, errno); + } } snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); loopfd = open(loopname, O_RDWR); -- cgit mrf-deployment