From patchwork Mon May 22 00:29:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 9739541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EC03E601C2 for ; Mon, 22 May 2017 00:29:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAABD283D1 for ; Mon, 22 May 2017 00:29:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBEC82857B; Mon, 22 May 2017 00:29:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCB6C283D1 for ; Mon, 22 May 2017 00:29:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932211AbdEVA3V (ORCPT ); Sun, 21 May 2017 20:29:21 -0400 Received: from imap.thunk.org ([74.207.234.97]:47964 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932083AbdEVA3U (ORCPT ); Sun, 21 May 2017 20:29:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=aWoWckO8t1vBTIBt32w9LYHm4MeQQIQoe/kWn2GCcH4=; b=laAcE6eOW2h22Z7HztYQpvxMdsAl6rpcLWKzBIzPuJTa161Gxp3bil5fhywpGiAGlJbO26VlggbTwYqrb9QjvjiuJr22ejEeYAu6qwOyuRWkUab87UIn91YSG0ST9U5xYBzrK7u6B4iNnJGe9I2MLy94BhhKH9y7v5AeMsX8K6Y=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.84_2) (envelope-from ) id 1dCbDp-0002Ix-UM; Mon, 22 May 2017 00:29:18 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id D819EC00589; Sun, 21 May 2017 20:29:15 -0400 (EDT) From: Theodore Ts'o To: fstests@vger.kernel.org Cc: eguan@redhat.com, Theodore Ts'o Subject: [PATCH -v2] src: fix compiler warnings Date: Sun, 21 May 2017 20:29:12 -0400 Message-Id: <20170522002912.12543-1-tytso@mit.edu> X-Mailer: git-send-email 2.11.0.rc0.7.gbe5a750 In-Reply-To: <20170502131823.GA7250@eguan.usersys.redhat.com> References: <20170502131823.GA7250@eguan.usersys.redhat.com> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Most of the fixes are printf format type warnings, but apparently GCC 6 is smart enough to realize is that if you don't do proper error checking with posix_memalign, the resulting pointer can be undefined, and whines about it. So while fixing this in aio-dio-fcntl-race, I also cleaned up the error checking and reporting. Signed-off-by: Theodore Ts'o --- src/aio-dio-regress/aio-dio-eof-race.c | 3 ++- src/aio-dio-regress/aio-dio-fcntl-race.c | 32 +++++++++++++++++++++++--------- src/dio-invalidate-cache.c | 6 ++++-- src/holetest.c | 8 ++++---- src/t_rename_overwrite.c | 3 ++- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/aio-dio-regress/aio-dio-eof-race.c b/src/aio-dio-regress/aio-dio-eof-race.c index bd71b030..bb1890b5 100644 --- a/src/aio-dio-regress/aio-dio-eof-race.c +++ b/src/aio-dio-regress/aio-dio-eof-race.c @@ -202,7 +202,8 @@ int main(int argc, char *argv[]) * a seamless buf_size worth of IO_PATTERN to the last block. */ if (memcmp(buf, cmp_buf, buf_size)) { - printf("corruption while extending from %ld\n", eof); + printf("corruption while extending from %lld\n", + (long long) eof); dump_buffer(buf, 0, buf_size); return 1; } diff --git a/src/aio-dio-regress/aio-dio-fcntl-race.c b/src/aio-dio-regress/aio-dio-fcntl-race.c index cdf97736..88a27472 100644 --- a/src/aio-dio-regress/aio-dio-fcntl-race.c +++ b/src/aio-dio-regress/aio-dio-fcntl-race.c @@ -92,12 +92,16 @@ int main(int argc, char **argv) return 1; } fd = open(argv[1], O_CREAT | O_TRUNC | O_RDWR, 0600); - if (fd < 0) + if (fd < 0) { + perror("open"); return 1; + } pid1 = fork(); - if (pid1 < 0) + if (pid1 < 0) { + perror("fork"); return 1; + } if (pid1 == 0) { struct timeval start, now, delta = { 0, 0 }; @@ -108,12 +112,15 @@ int main(int argc, char **argv) flags = fcntl(fd, F_GETFL); while (1) { ret = fcntl(fd, F_SETFL, flags | O_DIRECT); - if (ret) - return ret; + if (ret) { + perror("fcntl O_DIRECT"); + return 1; + } ret = fcntl(fd, F_SETFL, flags); - if (ret) - return ret; - + if (ret) { + perror("fcntl"); + return 1; + } gettimeofday(&now, NULL); timersub(&now, &start, &delta); if (delta.tv_sec >= LOOP_SECONDS) @@ -121,8 +128,15 @@ int main(int argc, char **argv) } } else { /* parent: AIO */ - void *buf; - posix_memalign(&buf, BUF_SIZE, BUF_SIZE); + void *buf = NULL; + int err; + + err = posix_memalign(&buf, BUF_SIZE, BUF_SIZE); + if (err || buf == NULL) { + fprintf(stderr, "posix_memalign failed: %s\n", + strerror(err)); + exit(1); + } /* Two tasks which performs unaligned aio will be serialized which maks race window wider */ pid2 = fork(); diff --git a/src/dio-invalidate-cache.c b/src/dio-invalidate-cache.c index 4c40c87d..0f87d668 100644 --- a/src/dio-invalidate-cache.c +++ b/src/dio-invalidate-cache.c @@ -160,7 +160,8 @@ static int run_test(const char *filename, int n_child, int blksz, off_t offset, /* seek, write, read and verify */ for (i = 0; i < nr_iter; i++) { memset(buf_wr, i + 1, blksz); - log("pwrite(fd_wr, %p, %d, %lu)\n", buf_wr, blksz, seekoff); + log("pwrite(fd_wr, %p, %d, %lld)\n", buf_wr, blksz, + (long long) seekoff); if (pwrite(fd_wr, buf_wr, blksz, seekoff) != blksz) { perror("direct write"); exit(EXIT_FAILURE); @@ -174,7 +175,8 @@ static int run_test(const char *filename, int n_child, int blksz, off_t offset, } } - log("pread(fd_rd, %p, %d, %lu)\n", buf_rd, blksz, seekoff); + log("pread(fd_rd, %p, %d, %lld)\n", buf_rd, blksz, + (long long) seekoff); if (pread(fd_rd, buf_rd, blksz, seekoff) != blksz) { perror("buffer read"); exit(EXIT_FAILURE); diff --git a/src/holetest.c b/src/holetest.c index edd85fe7..1939b35f 100644 --- a/src/holetest.c +++ b/src/holetest.c @@ -101,10 +101,10 @@ int verify_mapping(char *vastart, long npages, uint64_t *expect) for (i = 0; i < THREADS; i++) { if (*(uint64_t*)(va + page_offs[i]) != expect[i]) { printf("ERROR: thread %d, " - "offset %08lx, %08lx != %08lx\n", i, - (va + page_offs[i] - vastart), - *(uint64_t*)(va + page_offs[i]), - expect[i]); + "offset %08llx, %08llx != %08llx\n", i, + (unsigned long long) (va + page_offs[i] - vastart), + (unsigned long long) *(uint64_t*)(va + page_offs[i]), + (unsigned long long) expect[i]); errcnt++; } } diff --git a/src/t_rename_overwrite.c b/src/t_rename_overwrite.c index fe17f9d5..c5cdd1db 100644 --- a/src/t_rename_overwrite.c +++ b/src/t_rename_overwrite.c @@ -31,7 +31,8 @@ int main(int argc, char *argv[]) err(1, "fstat(%i)", fd); if (stbuf.st_nlink != 0) { - fprintf(stderr, "nlink is %lu, should be 0\n", stbuf.st_nlink); + fprintf(stderr, "nlink is %lu, should be 0\n", + (unsigned long) stbuf.st_nlink); return 1; }