From 9e49df6b2042178be3df85a9e0a02c9599dbba68 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 12 Mar 2009 15:38:51 -0700 Subject: Add gcc-fortify-source branch --- .topdeps | 1 + .topmsg | 14 ++++++++++++++ cmd/zdb/zdb.c | 2 +- cmd/ztest/ztest.c | 2 +- lib/libzpool/kernel.c | 2 +- 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 000000000..1f7391f92 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 000000000..fc8e21aea --- /dev/null +++ b/.topmsg @@ -0,0 +1,14 @@ +From: Brian Behlendorf +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 diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 0ced25865..1f1d6edca 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -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 diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 4503a3d02..e758b23af 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -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); diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index 89108fe5b..fc2a87fdb 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -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); } -- cgit v1.2.3 From 76a1c3140f18ed487406b9fa1bec4d2d158032aa Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 12 Mar 2009 15:39:25 -0700 Subject: New TopGit dependency: gcc-fortify-source --- .topdeps | 1 + 1 file changed, 1 insertion(+) diff --git a/.topdeps b/.topdeps index 8b9694c75..2cf45e304 100644 --- a/.topdeps +++ b/.topdeps @@ -11,3 +11,4 @@ gcc-shadow gcc-64bit-constants gcc-ident-pragmas gcc-missing-braces +gcc-fortify-source -- cgit v1.2.3