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
This commit is contained in:
parent
be5eb1ff8e
commit
0ff418982f
@ -48,6 +48,8 @@ extern "C" {
|
||||
#include "mntopts.h" // for build_iovec
|
||||
}
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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() {
|
||||
|
@ -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;
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -298,7 +298,7 @@ void FuseTest::expect_readdir(uint64_t ino, uint64_t off,
|
||||
}, 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user