]> granicus.if.org Git - zfs/commitdiff
Add gcc-fortify-source branch
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 12 Mar 2009 22:38:51 +0000 (15:38 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 12 Mar 2009 22:38:51 +0000 (15:38 -0700)
.topdeps [new file with mode: 0644]
.topmsg [new file with mode: 0644]
cmd/zdb/zdb.c
cmd/ztest/ztest.c
lib/libzpool/kernel.c

diff --git a/.topdeps b/.topdeps
new file mode 100644 (file)
index 0000000..1f7391f
--- /dev/null
+++ b/.topdeps
@@ -0,0 +1 @@
+master
diff --git a/.topmsg b/.topmsg
new file mode 100644 (file)
index 0000000..fc8e21a
--- /dev/null
+++ b/.topmsg
@@ -0,0 +1,14 @@
+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>
index 0ced258656bc41f276809762b0941451017797d4..1f1d6edca27e510091b3ca4b6b58844bb1f0f3ca 100644 (file)
@@ -1875,7 +1875,7 @@ zdb_dump_block_raw(void *buf, uint64_t size, int flags)
 {
        if (flags & ZDB_FLAG_BSWAP)
                byteswap_uint64_array(buf, size);
-       (void) write(2, buf, size);
+       VERIFY(write(fileno(stderr), buf, size) == size);
 }
 
 static void
index 4503a3d02802104262b458430f54318b7901ae92..e758b23afe9b54a54abd777560bf1d7941b9a760 100644 (file)
@@ -1170,7 +1170,7 @@ ztest_vdev_LUN_growth(ztest_args_t *za)
                 */
                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);
index 89108fe5b2b1bf0950eeec985282701da4a9a355..fc2a87fdbf6722ca4d2836ec22027fa6d37ce1c7 100644 (file)
@@ -764,7 +764,7 @@ umem_out_of_memory(void)
 {
        char errmsg[] = "out of memory -- generating core dump\n";
 
-       write(fileno(stderr), errmsg, sizeof (errmsg));
+       (void) fprintf(stderr, "%s", errmsg);
        abort();
        return (0);
 }