From 2436f2110af7cf305ebe5198e5e330cfcdd3a2c6 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Tue, 23 Jul 2024 21:06:55 +0200 Subject: [PATCH] tree-wide: NULL -> nullptr This is slightly more type safe and is more in line with modern C++. Change-Id: Ia7a8df1c7788085020d1bdc941d6f9cee356144e --- src/build-remote/build-remote.cc | 4 ++-- src/libstore/build/local-derivation-goal.cc | 2 +- src/libstore/globals.cc | 4 ++-- src/libstore/local-store.cc | 2 +- src/libstore/platform/darwin.cc | 8 ++++---- src/libutil/tarfile.cc | 4 ++-- .../resolve-system-dependencies.cc | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) 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/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/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 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);