From owner-svn-src-projects@freebsd.org Sun May 26 03:52:37 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE21C15BE96E for ; Sun, 26 May 2019 03:52:36 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 83DF16FBD3; Sun, 26 May 2019 03:52:36 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6EF62E404; Sun, 26 May 2019 03:52:36 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4Q3qaEs010756; Sun, 26 May 2019 03:52:36 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4Q3qZBT010750; Sun, 26 May 2019 03:52:35 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201905260352.x4Q3qZBT010750@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 26 May 2019 03:52:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r348285 - projects/fuse2/tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/tests/sys/fs/fusefs X-SVN-Commit-Revision: 348285 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 83DF16FBD3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 May 2019 03:52:37 -0000 Author: asomers Date: Sun May 26 03:52:35 2019 New Revision: 348285 URL: https://svnweb.freebsd.org/changeset/base/348285 Log: fusefs: more build fixes * Fix printf format strings on 32-bit OSes * Fix -Wclass-memaccess violation on GCC-8 caused by using memset on an object of non-trivial type. * Fix memory leak in MockFS::init * Fix -Wcast-align error on i386 in expect_readdir * Fix some heterogenous comparison errors on 32-bit OSes. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.cc projects/fuse2/tests/sys/fs/fusefs/mockfs.hh projects/fuse2/tests/sys/fs/fusefs/read.cc projects/fuse2/tests/sys/fs/fusefs/setattr.cc projects/fuse2/tests/sys/fs/fusefs/utils.cc Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Sat May 25 23:58:09 2019 (r348284) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Sun May 26 03:52:35 2019 (r348285) @@ -48,6 +48,8 @@ extern "C" { #include "mntopts.h" // for build_iovec } +#include + #include #include "mockfs.hh" @@ -153,10 +155,10 @@ void sigint_handler(int __unused sig) { void debug_fuseop(const mockfs_buf_in *in) { - printf("%-11s ino=%2lu", opcode2opname(in->header.opcode), + printf("%-11s ino=%2" PRIu64, opcode2opname(in->header.opcode), in->header.nodeid); if (verbosity > 1) { - printf(" uid=%5u gid=%5u pid=%5u unique=%lu len=%u", + printf(" uid=%5u gid=%5u pid=%5u unique=%" PRIu64 " len=%u", in->header.uid, in->header.gid, in->header.pid, in->header.unique, in->header.len); } @@ -173,11 +175,12 @@ void debug_fuseop(const mockfs_buf_in *in) in->body.open.flags, name); break; case FUSE_FLUSH: - printf(" fh=%#lx lock_owner=%lu", in->body.flush.fh, + printf(" fh=%#" PRIx64 " lock_owner=%" PRIu64, + in->body.flush.fh, in->body.flush.lock_owner); break; case FUSE_FORGET: - printf(" nlookup=%lu", in->body.forget.nlookup); + printf(" nlookup=%" PRIu64, in->body.forget.nlookup); break; case FUSE_FSYNC: printf(" flags=%#x", in->body.fsync.fsync_flags); @@ -186,10 +189,10 @@ void debug_fuseop(const mockfs_buf_in *in) printf(" flags=%#x", in->body.fsyncdir.fsync_flags); break; case FUSE_INTERRUPT: - printf(" unique=%lu", in->body.interrupt.unique); + printf(" unique=%" PRIu64, in->body.interrupt.unique); break; case FUSE_LINK: - printf(" oldnodeid=%lu", in->body.link.oldnodeid); + printf(" oldnodeid=%" PRIu64, in->body.link.oldnodeid); break; case FUSE_LOOKUP: printf(" %s", in->body.lookup); @@ -212,16 +215,17 @@ void debug_fuseop(const mockfs_buf_in *in) in->body.opendir.flags, in->body.opendir.mode); break; case FUSE_READ: - printf(" offset=%lu size=%u", in->body.read.offset, + printf(" offset=%" PRIu64 " size=%u", + in->body.read.offset, in->body.read.size); break; case FUSE_READDIR: - printf(" fh=%#lx offset=%lu size=%u", + printf(" fh=%#" PRIx64 " offset=%" PRIu64 " size=%u", in->body.readdir.fh, in->body.readdir.offset, in->body.readdir.size); break; case FUSE_RELEASE: - printf(" fh=%#lx flags=%#x lock_owner=%lu", + printf(" fh=%#" PRIx64 " flags=%#x lock_owner=%" PRIu64, in->body.release.fh, in->body.release.flags, in->body.release.lock_owner); @@ -238,25 +242,26 @@ void debug_fuseop(const mockfs_buf_in *in) if (in->body.setattr.valid & FATTR_GID) printf(" gid=%u", in->body.setattr.gid); if (in->body.setattr.valid & FATTR_SIZE) - printf(" size=%zu", in->body.setattr.size); + printf(" size=%" PRIu64, in->body.setattr.size); if (in->body.setattr.valid & FATTR_ATIME) - printf(" atime=%zu.%u", + printf(" atime=%" PRIu64 ".%u", in->body.setattr.atime, in->body.setattr.atimensec); if (in->body.setattr.valid & FATTR_MTIME) - printf(" mtime=%zu.%u", + printf(" mtime=%" PRIu64 ".%u", in->body.setattr.mtime, in->body.setattr.mtimensec); if (in->body.setattr.valid & FATTR_FH) - printf(" fh=%zu", in->body.setattr.fh); + printf(" fh=%" PRIu64 "", in->body.setattr.fh); break; case FUSE_SETLK: - printf(" fh=%#lx owner=%lu type=%u pid=%u", + printf(" fh=%#" PRIx64 " owner=%" PRIu64 + " type=%u pid=%u", in->body.setlk.fh, in->body.setlk.owner, in->body.setlk.lk.type, in->body.setlk.lk.pid); if (verbosity >= 2) { - printf(" range=[%lu-%lu]", + printf(" range=[%" PRIu64 "-%" PRIu64 "]", in->body.setlk.lk.start, in->body.setlk.lk.end); } @@ -272,7 +277,8 @@ void debug_fuseop(const mockfs_buf_in *in) printf(" %s=%s", name, value); break; case FUSE_WRITE: - printf(" fh=%#lx offset=%lu size=%u flags=%u", + printf(" fh=%#" PRIx64 " offset=%" PRIu64 + " size=%u flags=%u", in->body.write.fh, in->body.write.offset, in->body.write.size, in->body.write.write_flags); @@ -389,15 +395,14 @@ void MockFS::init(uint32_t flags) { mockfs_buf_in *in; mockfs_buf_out *out; - in = (mockfs_buf_in*) malloc(sizeof(*in)); + in = new mockfs_buf_in; ASSERT_TRUE(in != NULL); - out = (mockfs_buf_out*) malloc(sizeof(*out)); + out = new mockfs_buf_out; ASSERT_TRUE(out != NULL); read_request(in); ASSERT_EQ(FUSE_INIT, in->header.opcode); - memset(out, 0, sizeof(*out)); out->header.unique = in->header.unique; out->header.error = 0; out->body.init.major = FUSE_KERNEL_VERSION; @@ -418,7 +423,8 @@ void MockFS::init(uint32_t flags) { SET_OUT_HEADER_LEN(out, init); write(m_fuse_fd, out, out->header.len); - free(in); + delete out; + delete in; } void MockFS::kill_daemon() { Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.hh ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Sat May 25 23:58:09 2019 (r348284) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Sun May 26 03:52:35 2019 (r348285) @@ -166,7 +166,7 @@ union fuse_payloads_out { fuse_create_out create; fuse_create_out_7_8 create_7_8; /* The protocol places no limits on the size of bytes */ - uint8_t bytes[0x20000]; + uint8_t bytes[0x20000]; fuse_entry_out entry; fuse_entry_out_7_8 entry_7_8; fuse_lk_out getlk; Modified: projects/fuse2/tests/sys/fs/fusefs/read.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/read.cc Sat May 25 23:58:09 2019 (r348284) +++ projects/fuse2/tests/sys/fs/fusefs/read.cc Sun May 26 03:52:35 2019 (r348285) @@ -486,9 +486,8 @@ TEST_F(ReadCacheable, mmap) uint64_t ino = 42; int fd; ssize_t len; - ssize_t bufsize = strlen(CONTENTS); + size_t bufsize = strlen(CONTENTS); void *p; - //char buf[bufsize]; len = getpagesize(); @@ -674,7 +673,7 @@ TEST_F(ReadCacheable, sendfile) const char *CONTENTS = "abcdefgh"; uint64_t ino = 42; int fd; - ssize_t bufsize = strlen(CONTENTS); + size_t bufsize = strlen(CONTENTS); char buf[bufsize]; int sp[2]; off_t sbytes; @@ -703,7 +702,8 @@ TEST_F(ReadCacheable, sendfile) ASSERT_EQ(0, sendfile(fd, sp[1], 0, bufsize, NULL, &sbytes, 0)) << strerror(errno); - ASSERT_EQ(bufsize, read(sp[0], buf, bufsize)) << strerror(errno); + ASSERT_EQ((ssize_t)bufsize, read(sp[0], buf, bufsize)) + << strerror(errno); ASSERT_EQ(0, memcmp(buf, CONTENTS, bufsize)); close(sp[1]); Modified: projects/fuse2/tests/sys/fs/fusefs/setattr.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/setattr.cc Sat May 25 23:58:09 2019 (r348284) +++ projects/fuse2/tests/sys/fs/fusefs/setattr.cc Sun May 26 03:52:35 2019 (r348285) @@ -495,7 +495,7 @@ TEST_F(Setattr, truncate_discards_cached_data) { SET_OUT_HEADER_LEN(out, write); out->body.attr.attr.ino = ino; out->body.write.size = in->body.write.size; - cur_size = std::max(cur_size, + cur_size = std::max((uint64_t)cur_size, in->body.write.size + in->body.write.offset); }))); @@ -522,8 +522,8 @@ TEST_F(Setattr, truncate_discards_cached_data) { }, Eq(true)), _) ).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto out) { - auto osize = std::min(cur_size - in->body.read.offset, - (size_t)in->body.read.size); + auto osize = std::min((uint64_t)cur_size - in->body.read.offset, + (uint64_t)in->body.read.size); out->header.len = sizeof(struct fuse_out_header) + osize; if (should_have_data) memset(out->body.bytes, 'X', osize); Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Sat May 25 23:58:09 2019 (r348284) +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Sun May 26 03:52:35 2019 (r348285) @@ -298,7 +298,7 @@ void FuseTest::expect_readdir(uint64_t ino, uint64_t o }, Eq(true)), _) ).WillRepeatedly(Invoke(ReturnImmediate([=](auto in, auto out) { - struct fuse_dirent *fde = (struct fuse_dirent*)out->body.bytes; + struct fuse_dirent *fde = (struct fuse_dirent*)&(out->body); int i = 0; out->header.error = 0;