--- /dev/null
+From: Brian Behlendorf <behlendorf1@llnl.gov>
+Subject: [PATCH] gcc fortify source
+
+Resolve issues uncovered by -D_FORTIFY_SOURCE=2, the default redhat
+macro's file adds this option to the cflags. This causes warnings
+of the following type designed to keep the developer honest:
+
+ warning: ignoring return value of 'foo', declared
+ with attribute warn_unused_result
+
+The short term fix is to wrap these calls in VERIFY() to check the
+return code. The code was already assusing these would never fail.
+
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
{
if (flags & ZDB_FLAG_BSWAP)
byteswap_uint64_array(buf, size);
- (void) write(2, buf, size);
+ VERIFY(write(fileno(stderr), buf, size) == size);
}
static void
*/
if (fsize < 2 * zopt_vdev_size) {
size_t newsize = fsize + ztest_random(fsize / 32);
- (void) ftruncate(fd, newsize);
+ VERIFY(ftruncate(fd, newsize) == 0);
if (zopt_verbose >= 6) {
(void) printf("%s grew from %lu to %lu bytes\n",
dev_name, (ulong_t)fsize, (ulong_t)newsize);
{
char errmsg[] = "out of memory -- generating core dump\n";
- write(fileno(stderr), errmsg, sizeof (errmsg));
+ (void) fprintf(stderr, "%s", errmsg);
abort();
return (0);
}