From owner-svn-src-projects@freebsd.org Mon May 27 22:34:52 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 3999D15ACFB6 for ; Mon, 27 May 2019 22:34:52 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2547689BAE; Mon, 27 May 2019 22:34:50 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lj1-f175.google.com with SMTP id r76so5048973lja.12; Mon, 27 May 2019 15:34:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=83+yuguPuEx5uq0bSyuVCIo7byt5C3QhpTXT0bNC0IQ=; b=eJiWzPvyEdqTtKdUAwoHQ83SgzCn9NaI0QvIfN6ItDHcJhxZF4/YCEVO0Hq3UI1syb wuuEOoCDPDcvFf1pvYHO3MpUDDqhAa5pktRznodfsXi+2FsRAWJRvx59CsceIO/MD14I y0SO8DQ5VCy9F4CZCpL8idfUxra4LdPva0WPTmU0qB0R/MG2D2iFRHV4iU7VU2KlfTKF 2WAX3tbotAk+9XQh2ardG7fXBl/tsD3mbooVZ6Z8JfGcThTjp6evGDHuifQxJCvONDGV LYkPj98Cr9iHj716MZawHxvWeG6YtkETSEHYHMqo6ExtO790fx4mBcWw7xQBL9E73xuZ R3fg== X-Gm-Message-State: APjAAAVXC/iVnLK4oZJ3EAhSuCgv7ZCqScf2sCBRF6q1t4bqSCXXIwgE xV0Tpj3uaA8UTm0rJP0Baq8X9gymj1Z4hxulG98= X-Google-Smtp-Source: APXvYqxaI6riiflAu53vObwQuKDBRxAAG6AY67fMydvsyYnWfqkv6VErr+YVCxTnyx0XIgIQMxQ76N4awoZTxmbF7g0= X-Received: by 2002:a2e:1284:: with SMTP id 4mr31482965ljs.138.1558994987650; Mon, 27 May 2019 15:09:47 -0700 (PDT) MIME-Version: 1.0 References: <201905260352.x4Q3qZBT010750@repo.freebsd.org> <276AB18D-F1C7-47FF-B070-A019352FB615@gmail.com> In-Reply-To: <276AB18D-F1C7-47FF-B070-A019352FB615@gmail.com> From: Alan Somers Date: Mon, 27 May 2019 16:09:35 -0600 Message-ID: Subject: Re: svn commit: r348285 - projects/fuse2/tests/sys/fs/fusefs To: Enji Cooper Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 2547689BAE X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.208.175 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[freebsd.org]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; NEURAL_HAM_SHORT(-0.74)[-0.736,0]; RCVD_IN_DNSWL_NONE(0.00)[175.208.85.209.list.dnswl.org : 127.0.5.0]; RCVD_TLS_LAST(0.00)[]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; FREEMAIL_TO(0.00)[gmail.com]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; IP_SCORE(-1.25)[ip: (-0.54), ipnet: 209.85.128.0/17(-3.39), asn: 15169(-2.28), country: US(-0.06)]; RCVD_COUNT_TWO(0.00)[2] 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: Mon, 27 May 2019 22:34:52 -0000 On Sun, May 26, 2019 at 8:02 AM Enji Cooper wrote: > > > On May 25, 2019, at 20:52, Alan Somers wrote: > > 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 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Sat May 25 23:58:09 2= 019 (r348284) > +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Sun May 26 03:52:35 2= 019 (r348285) > > > ... > > - in =3D (mockfs_buf_in*) malloc(sizeof(*in)); > + in =3D new mockfs_buf_in; > ASSERT_TRUE(in !=3D NULL); > - out =3D (mockfs_buf_out*) malloc(sizeof(*out)); > + out =3D new mockfs_buf_out; > ASSERT_TRUE(out !=3D NULL); > > read_request(in); > ASSERT_EQ(FUSE_INIT, in->header.opcode); > > - memset(out, 0, sizeof(*out)); > out->header.unique =3D in->header.unique; > out->header.error =3D 0; > out->body.init.major =3D 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; > > > Given that the tests are currently using C++14, it seems like it would ma= ke sense to use smart pointers here to manage the scope/lifetime of the obj= ects, as this could leak if someone added an early return or an exception w= as thrown. Ref: https://en.cppreference.com/book/intro/smart_pointers. Done! Nothing like using C++ smart pointers to make me miss Rust. > > } > > void MockFS::kill_daemon() { > > Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.hh > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Sat May 25 23:58:09 2= 019 (r348284) > +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Sun May 26 03:52:35 2= 019 (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]; > > > What does this hex value represent? Could it be made into a constant? It's just "a big buffer" used for different purposes by different tests. The size is arbitrary. I've tried to make that more clear in the comment. > > ... > > - cur_size =3D std::max(cur_size, > + cur_size =3D std::max((uint64_t)cur_size, > in->body.write.size + in->body.write.offset); > }))); > > > Casting like this is legal, but this is the C way of doing casting. C++11= and newer recommends using static_cast for all compile time casting and dy= namic_cast for all runtime casting. Done! Here, at least. In some other locations I've stuck with C-style casting because it involves significantly fewer characters, so I find it more readable. > > Thanks :)! > -Enji Since you're interested in C++ issues, would you mind taking a look at a painful compiler error I'm getting? This only happens with GCC-8, not Clang, so I'm only seeing it in the riscv.riscv64 buildworld. In file included from /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/algorithm:645, from /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/__string:57, from /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/string_view:176, from /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/string:505, from /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/__locale:15, from /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/ios:216, from /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/ostream:138, from /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/private/gtest/gtest.h:56, from /home/asomers/freebsd/base/projects/fuse2/tests/sys/fs/fusefs/mockfs.cc:53: /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/functional: In instantiation of 'std::__1::__function::__value_func<_Rp(_ArgTypes ...)>::__value_func(_Fp&&, _Alloc) [with _Fp =3D ReturnImmediate(std::__1::function)::; _Alloc =3D std::__1::allocator):: >; _Rp =3D void; _ArgTypes =3D {const mockfs_buf_in&, std::__1::vector >, std::__1::allocator > > >&}]': /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/functional:2290:46: required from 'std::__1::function<_Rp(_ArgTypes ...)>::function(_Fp) [with _Fp =3D ReturnImmediate(std::__1::function)::; =3D void; _Rp =3D void; _ArgTypes =3D {const mockfs_buf_in&, std::__1::vector >, std::__1::allocator > > >&}]' /home/asomers/freebsd/base/projects/fuse2/tests/sys/fs/fusefs/mockfs.cc:149= :3: required from here /scratch/tmp/asomers/obj/home/asomers/freebsd/base/projects/fuse2/riscv.ris= cv64/tmp/usr/include/c++/v1/functional:1711:36: error: placement new constructing an object of type '_Fun' {aka 'std::__1::__function::__func)::, std::__1::allocator):: >, void(const mockfs_buf_in&, std::__1::vector >&)>'} and size '64' in a region of type 'std::__1::aligned_storage<24>::type' and size '32' [-Werror=3Dplacement-new=3D] ::new ((void*)&__buf_) _Fun(_VSTD::move(__f), _Alloc(__af)); ^~~~~~ Do you have any idea how to fix that? -Alan