libutil: use uniform initialization in _deletePath

Otherwise I get a compiler error when building for NetBSD:

src/libutil/util.cc: In function 'void nix::_deletePath(const Path&, uint64_t&)':
src/libutil/util.cc:438:17: error: base operand of '->' is not a pointer
  438 |     AutoCloseFD dirfd(open(dir.c_str(), O_RDONLY));
      |                 ^~~~~
src/libutil/util.cc:439:10: error: 'dirfd' was not declared in this scope
  439 |     if (!dirfd) {
      |          ^~~~~
src/libutil/util.cc:444:17: error: 'dirfd' was not declared in this scope
  444 |     _deletePath(dirfd.get(), path, bytesFreed);
      |                 ^~~~~
This commit is contained in:
Alyssa Ross 2021-07-24 09:19:48 +00:00
parent 97be92569c
commit 369ed71858
No known key found for this signature in database
GPG key ID: F9DBED4859B271C0

View file

@ -435,7 +435,7 @@ static void _deletePath(const Path & path, uint64_t & bytesFreed)
if (dir == "") if (dir == "")
dir = "/"; dir = "/";
AutoCloseFD dirfd(open(dir.c_str(), O_RDONLY)); AutoCloseFD dirfd{open(dir.c_str(), O_RDONLY)};
if (!dirfd) { if (!dirfd) {
if (errno == ENOENT) return; if (errno == ENOENT) return;
throw SysError("opening directory '%1%'", path); throw SysError("opening directory '%1%'", path);