diff options
-rw-r--r-- | package.nix | 38 | ||||
-rw-r--r-- | src/build-remote/build-remote.cc | 4 | ||||
-rw-r--r-- | src/libstore/build/local-derivation-goal.cc | 2 | ||||
-rw-r--r-- | src/libstore/globals.cc | 4 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 2 | ||||
-rw-r--r-- | src/libstore/platform/darwin.cc | 8 | ||||
-rw-r--r-- | src/libutil/file-system.cc | 16 | ||||
-rw-r--r-- | src/libutil/tarfile.cc | 4 | ||||
-rw-r--r-- | src/nix/diff-closures.cc | 15 | ||||
-rw-r--r-- | src/resolve-system-dependencies/resolve-system-dependencies.cc | 2 |
10 files changed, 34 insertions, 61 deletions
diff --git a/package.nix b/package.nix index 16477a6a2..bde48ae4b 100644 --- a/package.nix +++ b/package.nix @@ -92,31 +92,19 @@ let # Reimplementation of Nixpkgs' Meson cross file, with some additions to make # it actually work. - mesonCrossFile = - let - cpuFamily = - platform: - with platform; - if isAarch32 then - "arm" - else if isx86_32 then - "x86" - else - platform.uname.processor; - in - builtins.toFile "lix-cross-file.conf" '' - [properties] - # Meson is convinced that if !buildPlatform.canExecute hostPlatform then we cannot - # build anything at all, which is not at all correct. If we can't execute the host - # platform, we'll just disable tests and doc gen. - needs_exe_wrapper = false - - [binaries] - # Meson refuses to consider any CMake binary during cross compilation if it's - # not explicitly specified here, in the cross file. - # https://github.com/mesonbuild/meson/blob/0ed78cf6fa6d87c0738f67ae43525e661b50a8a2/mesonbuild/cmake/executor.py#L72 - cmake = 'cmake' - ''; + mesonCrossFile = builtins.toFile "lix-cross-file.conf" '' + [properties] + # Meson is convinced that if !buildPlatform.canExecute hostPlatform then we cannot + # build anything at all, which is not at all correct. If we can't execute the host + # platform, we'll just disable tests and doc gen. + needs_exe_wrapper = false + + [binaries] + # Meson refuses to consider any CMake binary during cross compilation if it's + # not explicitly specified here, in the cross file. + # https://github.com/mesonbuild/meson/blob/0ed78cf6fa6d87c0738f67ae43525e661b50a8a2/mesonbuild/cmake/executor.py#L72 + cmake = 'cmake' + ''; # The internal API docs need these for the build, but if we're not building # Nix itself, then these don't need to be propagated. diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index fb90403a0..99bbc62d5 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -236,9 +236,9 @@ static int main_build_remote(int argc, char * * argv) } #if __APPLE__ - futimes(bestSlotLock.get(), NULL); + futimes(bestSlotLock.get(), nullptr); #else - futimens(bestSlotLock.get(), NULL); + futimens(bestSlotLock.get(), nullptr); #endif lock.reset(); diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index 7d1d339e8..da2433326 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -1882,7 +1882,7 @@ void LocalDerivationGoal::runChild() sandboxArgs.push_back("_ALLOW_LOCAL_NETWORKING"); sandboxArgs.push_back("1"); } - if (sandbox_init_with_parameters(sandboxProfile.c_str(), 0, stringsToCharPtrs(sandboxArgs).data(), NULL)) { + if (sandbox_init_with_parameters(sandboxProfile.c_str(), 0, stringsToCharPtrs(sandboxArgs).data(), nullptr)) { writeFull(STDERR_FILENO, "failed to configure sandbox\n"); _exit(1); } diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 02d26e034..6cfa3ffac 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -177,14 +177,14 @@ static bool hasVirt() { size_t size; size = sizeof(hasVMM); - if (sysctlbyname("kern.hv_vmm_present", &hasVMM, &size, NULL, 0) == 0) { + if (sysctlbyname("kern.hv_vmm_present", &hasVMM, &size, nullptr, 0) == 0) { if (hasVMM) return false; } // whether the kernel and hardware supports virt size = sizeof(hvSupport); - if (sysctlbyname("kern.hv_support", &hvSupport, &size, NULL, 0) == 0) { + if (sysctlbyname("kern.hv_support", &hvSupport, &size, nullptr, 0) == 0) { return hvSupport == 1; } else { return false; diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 10d43ee3e..f09d1bdab 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -557,7 +557,7 @@ void LocalStore::openDB(State & state, bool create) if (sqlite3_exec(db, "pragma main.journal_size_limit = 1099511627776;", 0, 0, 0) != SQLITE_OK) SQLiteError::throw_(db, "setting journal_size_limit"); int enable = 1; - if (sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, &enable) != SQLITE_OK) + if (sqlite3_file_control(db, nullptr, SQLITE_FCNTL_PERSIST_WAL, &enable) != SQLITE_OK) SQLiteError::throw_(db, "setting persistent WAL mode"); } diff --git a/src/libstore/platform/darwin.cc b/src/libstore/platform/darwin.cc index 83b4b4183..1b591fde3 100644 --- a/src/libstore/platform/darwin.cc +++ b/src/libstore/platform/darwin.cc @@ -235,15 +235,15 @@ void DarwinLocalDerivationGoal::execBuilder(std::string builder, Strings args, S if (drv->platform == "aarch64-darwin") { // Unset kern.curproc_arch_affinity so we can escape Rosetta int affinity = 0; - sysctlbyname("kern.curproc_arch_affinity", NULL, NULL, &affinity, sizeof(affinity)); + sysctlbyname("kern.curproc_arch_affinity", nullptr, nullptr, &affinity, sizeof(affinity)); cpu_type_t cpu = CPU_TYPE_ARM64; - posix_spawnattr_setbinpref_np(&attrp, 1, &cpu, NULL); + posix_spawnattr_setbinpref_np(&attrp, 1, &cpu, nullptr); } else if (drv->platform == "x86_64-darwin") { cpu_type_t cpu = CPU_TYPE_X86_64; - posix_spawnattr_setbinpref_np(&attrp, 1, &cpu, NULL); + posix_spawnattr_setbinpref_np(&attrp, 1, &cpu, nullptr); } - posix_spawn(NULL, builder.c_str(), NULL, &attrp, stringsToCharPtrs(args).data(), stringsToCharPtrs(envStrs).data()); + posix_spawn(nullptr, builder.c_str(), nullptr, &attrp, stringsToCharPtrs(args).data(), stringsToCharPtrs(envStrs).data()); } } diff --git a/src/libutil/file-system.cc b/src/libutil/file-system.cc index f0199d36f..e2319ec59 100644 --- a/src/libutil/file-system.cc +++ b/src/libutil/file-system.cc @@ -21,22 +21,14 @@ Path absPath(Path path, std::optional<PathView> dir, bool resolveSymlinks) { if (path.empty() || path[0] != '/') { if (!dir) { -#ifdef __GNU__ - /* GNU (aka. GNU/Hurd) doesn't have any limitation on path - lengths and doesn't define `PATH_MAX'. */ - char *buf = getcwd(NULL, 0); - if (buf == NULL) -#else char buf[PATH_MAX]; - if (!getcwd(buf, sizeof(buf))) -#endif + if (!getcwd(buf, sizeof(buf))) { throw SysError("cannot get cwd"); + } path = concatStrings(buf, "/", path); -#ifdef __GNU__ - free(buf); -#endif - } else + } else { path = concatStrings(*dir, "/", path); + } } return canonPath(path, resolveSymlinks); } diff --git a/src/libutil/tarfile.cc b/src/libutil/tarfile.cc index 760a5a65a..c7f9499fd 100644 --- a/src/libutil/tarfile.cc +++ b/src/libutil/tarfile.cc @@ -54,7 +54,7 @@ TarArchive::TarArchive(Source & source, bool raw) : buffer(65536) archive_read_support_format_raw(archive); archive_read_support_format_empty(archive); } - archive_read_set_option(archive, NULL, "mac-ext", NULL); + archive_read_set_option(archive, nullptr, "mac-ext", nullptr); check(archive_read_open(archive, (void *)this, callback_open, callback_read, callback_close), "Failed to open archive (%s)"); } @@ -65,7 +65,7 @@ TarArchive::TarArchive(const Path & path) archive_read_support_filter_all(archive); archive_read_support_format_all(archive); - archive_read_set_option(archive, NULL, "mac-ext", NULL); + archive_read_set_option(archive, nullptr, "mac-ext", nullptr); check(archive_read_open_filename(archive, path.c_str(), 16384), "failed to open archive: %s"); } diff --git a/src/nix/diff-closures.cc b/src/nix/diff-closures.cc index 5eda309d5..dac4625e6 100644 --- a/src/nix/diff-closures.cc +++ b/src/nix/diff-closures.cc @@ -24,24 +24,17 @@ GroupedPaths getClosureInfo(ref<Store> store, const StorePath & toplevel) GroupedPaths groupedPaths; - for (auto & path : closure) { + for (auto const & path : closure) { /* Strip the output name. Unfortunately this is ambiguous (we can't distinguish between output names like "bin" and version suffixes like "unstable"). */ static std::regex regex("(.*)-([a-z]+|lib32|lib64)"); - std::smatch match; + std::cmatch match; std::string name{path.name()}; - // Used to keep name alive through being potentially overwritten below - // (to not invalidate the references from the regex result) - // - // n.b. cannot be just path.name().{begin,end}() since that returns const - // char *, which does not, for some reason, convert as required on - // libstdc++. Seems like a libstdc++ bug or standard bug to me... we - // can afford the allocation in any case. - const std::string origName{path.name()}; + std::string_view const origName = path.name(); std::string outputName; - if (std::regex_match(origName, match, regex)) { + if (std::regex_match(origName.begin(), origName.end(), match, regex)) { name = match[1]; outputName = match[2]; } diff --git a/src/resolve-system-dependencies/resolve-system-dependencies.cc b/src/resolve-system-dependencies/resolve-system-dependencies.cc index 2c4b06791..319f7108e 100644 --- a/src/resolve-system-dependencies/resolve-system-dependencies.cc +++ b/src/resolve-system-dependencies/resolve-system-dependencies.cc @@ -48,7 +48,7 @@ std::set<std::string> runResolver(const Path & filename) return {}; } - char* obj = (char*) mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd.get(), 0); + char* obj = (char*) mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fd.get(), 0); if (!obj) throw SysError("mmapping '%s'", filename); |