From 8a802fd670028f518c3c9b7cce7511bf8e626c67 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 17 Mar 2026 16:35:16 -0700 Subject: [PATCH] [wpilib] Rename private constants to all caps --- ntcoreffi/src/main/native/cpp/DataLogManager.cpp | 4 ++-- .../src/main/native/cpp/system/DataLogManager.cpp | 14 +++++++------- wpilibc/src/main/native/cpp/system/Tracer.cpp | 2 +- wpilibc/src/main/native/cpp/system/Watchdog.cpp | 2 +- .../src/main/native/include/wpi/system/Tracer.hpp | 2 +- .../main/native/include/wpi/system/Watchdog.hpp | 2 +- .../java/org/wpilib/system/DataLogManager.java | 14 +++++++------- .../src/main/java/org/wpilib/system/Tracer.java | 4 ++-- .../src/main/java/org/wpilib/system/Watchdog.java | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ntcoreffi/src/main/native/cpp/DataLogManager.cpp b/ntcoreffi/src/main/native/cpp/DataLogManager.cpp index a587c854f0..d22a7ff169 100644 --- a/ntcoreffi/src/main/native/cpp/DataLogManager.cpp +++ b/ntcoreffi/src/main/native/cpp/DataLogManager.cpp @@ -219,7 +219,7 @@ struct Instance { // if less than this much free space, delete log files until there is this much // free space OR there are this many files remaining. static constexpr uintmax_t kFreeSpaceThreshold = 50000000; -static constexpr int kFileCountThreshold = 10; +static constexpr int FILE_COUNT_THRESHOLD = 10; static std::string MakeLogDir(std::string_view dir) { if (!dir.empty()) { @@ -303,7 +303,7 @@ void Thread::Main() { int count = entries.size(); for (auto&& entry : entries) { --count; - if (count < kFileCountThreshold) { + if (count < FILE_COUNT_THRESHOLD) { break; } auto size = entry.file_size(); diff --git a/wpilibc/src/main/native/cpp/system/DataLogManager.cpp b/wpilibc/src/main/native/cpp/system/DataLogManager.cpp index a4ea1eb186..9c487b2cf2 100644 --- a/wpilibc/src/main/native/cpp/system/DataLogManager.cpp +++ b/wpilibc/src/main/native/cpp/system/DataLogManager.cpp @@ -63,8 +63,8 @@ struct Instance { // if less than this much free space, delete log files until there is this much // free space OR there are this many files remaining. -static constexpr uintmax_t kFreeSpaceThreshold = 50000000; -static constexpr int kFileCountThreshold = 10; +static constexpr uintmax_t FREE_SPACE_THRESHOLD = 50000000; +static constexpr int FILE_COUNT_THRESHOLD = 10; static std::string MakeLogDir(std::string_view dir) { if (!dir.empty()) { @@ -132,7 +132,7 @@ void Thread::Main() { } else { freeSpace = UINTMAX_MAX; } - if (freeSpace < kFreeSpaceThreshold) { + if (freeSpace < FREE_SPACE_THRESHOLD) { // Delete oldest WPILIB_*.wpilog files (ignore WPILIB_TBD_*.wpilog as we // just created one) std::vector entries; @@ -152,7 +152,7 @@ void Thread::Main() { int count = entries.size(); for (auto&& entry : entries) { --count; - if (count < kFileCountThreshold) { + if (count < FILE_COUNT_THRESHOLD) { break; } auto size = entry.file_size(); @@ -160,7 +160,7 @@ void Thread::Main() { WPILIB_ReportWarning("DataLogManager: Deleted {}", entry.path().string()); freeSpace += size; - if (freeSpace >= kFreeSpaceThreshold) { + if (freeSpace >= FREE_SPACE_THRESHOLD) { break; } } else { @@ -168,13 +168,13 @@ void Thread::Main() { entry.path().string()); } } - } else if (freeSpace < 2 * kFreeSpaceThreshold) { + } else if (freeSpace < 2 * FREE_SPACE_THRESHOLD) { WPILIB_ReportError( warn::Warning, "DataLogManager: Log storage device has {} MB of free space " "remaining! Logs will get deleted below {} MB of free space. " "Consider deleting logs off the storage device.", - freeSpace / 1000000, kFreeSpaceThreshold / 1000000); + freeSpace / 1000000, FREE_SPACE_THRESHOLD / 1000000); } } diff --git a/wpilibc/src/main/native/cpp/system/Tracer.cpp b/wpilibc/src/main/native/cpp/system/Tracer.cpp index e30233366b..e40c6033db 100644 --- a/wpilibc/src/main/native/cpp/system/Tracer.cpp +++ b/wpilibc/src/main/native/cpp/system/Tracer.cpp @@ -45,7 +45,7 @@ void Tracer::PrintEpochs(wpi::util::raw_ostream& os) { using std::chrono::microseconds; auto now = wpi::hal::monotonic_clock::now(); - if (now - m_lastEpochsPrintTime > kMinPrintPeriod) { + if (now - m_lastEpochsPrintTime > MIN_PRINT_PERIOD) { m_lastEpochsPrintTime = now; for (const auto& epoch : m_epochs) { os << fmt::format( diff --git a/wpilibc/src/main/native/cpp/system/Watchdog.cpp b/wpilibc/src/main/native/cpp/system/Watchdog.cpp index fb48f5d484..c2a444e439 100644 --- a/wpilibc/src/main/native/cpp/system/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/system/Watchdog.cpp @@ -107,7 +107,7 @@ void Watchdog::Impl::Main() { auto watchdog = m_watchdogs.pop(); wpi::units::second_t now{curTime * 1e-6}; - if (now - watchdog->m_lastTimeoutPrintTime > kMinPrintPeriod) { + if (now - watchdog->m_lastTimeoutPrintTime > MIN_PRINT_PERIOD) { watchdog->m_lastTimeoutPrintTime = now; if (!watchdog->m_suppressTimeoutMessage) { WPILIB_ReportWarning("Watchdog not fed within {:.6f}s", diff --git a/wpilibc/src/main/native/include/wpi/system/Tracer.hpp b/wpilibc/src/main/native/include/wpi/system/Tracer.hpp index 263cea1dac..b7245a5e57 100644 --- a/wpilibc/src/main/native/include/wpi/system/Tracer.hpp +++ b/wpilibc/src/main/native/include/wpi/system/Tracer.hpp @@ -63,7 +63,7 @@ class Tracer { void PrintEpochs(wpi::util::raw_ostream& os); private: - static constexpr std::chrono::milliseconds kMinPrintPeriod{1000}; + static constexpr std::chrono::milliseconds MIN_PRINT_PERIOD{1000}; wpi::hal::monotonic_clock::time_point m_startTime; wpi::hal::monotonic_clock::time_point m_lastEpochsPrintTime; diff --git a/wpilibc/src/main/native/include/wpi/system/Watchdog.hpp b/wpilibc/src/main/native/include/wpi/system/Watchdog.hpp index c64968c3ac..4260069dc5 100644 --- a/wpilibc/src/main/native/include/wpi/system/Watchdog.hpp +++ b/wpilibc/src/main/native/include/wpi/system/Watchdog.hpp @@ -112,7 +112,7 @@ class Watchdog { private: // Used for timeout print rate-limiting - static constexpr auto kMinPrintPeriod = 1_s; + static constexpr auto MIN_PRINT_PERIOD = 1_s; wpi::units::second_t m_startTime = 0_s; wpi::units::second_t m_timeout; diff --git a/wpilibj/src/main/java/org/wpilib/system/DataLogManager.java b/wpilibj/src/main/java/org/wpilib/system/DataLogManager.java index 027325a122..48f6fe0107 100644 --- a/wpilibj/src/main/java/org/wpilib/system/DataLogManager.java +++ b/wpilibj/src/main/java/org/wpilib/system/DataLogManager.java @@ -62,8 +62,8 @@ public final class DataLogManager { // if less than this much free space, delete log files until there is this much free space // OR there are this many files remaining. - private static final long kFreeSpaceThreshold = 50000000L; - private static final int kFileCountThreshold = 10; + private static final long FREE_SPACE_THRESHOLD = 50000000L; + private static final int FILE_COUNT_THRESHOLD = 10; private DataLogManager() {} @@ -308,7 +308,7 @@ public final class DataLogManager { { File logDir = new File(m_logDir); long freeSpace = logDir.getUsableSpace(); - if (freeSpace < kFreeSpaceThreshold) { + if (freeSpace < FREE_SPACE_THRESHOLD) { // Delete oldest WPILIB_*.wpilog files (ignore WPILIB_TBD_*.wpilog as we just created one) File[] files = logDir.listFiles( @@ -321,14 +321,14 @@ public final class DataLogManager { int count = files.length; for (File file : files) { --count; - if (count < kFileCountThreshold) { + if (count < FILE_COUNT_THRESHOLD) { break; } long length = file.length(); if (file.delete()) { DriverStation.reportWarning("DataLogManager: Deleted " + file.getName(), false); freeSpace += length; - if (freeSpace >= kFreeSpaceThreshold) { + if (freeSpace >= FREE_SPACE_THRESHOLD) { break; } } else { @@ -336,12 +336,12 @@ public final class DataLogManager { } } } - } else if (freeSpace < 2 * kFreeSpaceThreshold) { + } else if (freeSpace < 2 * FREE_SPACE_THRESHOLD) { DriverStation.reportWarning( "DataLogManager: Log storage device has " + freeSpace / 1000000 + " MB of free space remaining! Logs will get deleted below " - + kFreeSpaceThreshold / 1000000 + + FREE_SPACE_THRESHOLD / 1000000 + " MB of free space. " + "Consider deleting logs off the storage device.", false); diff --git a/wpilibj/src/main/java/org/wpilib/system/Tracer.java b/wpilibj/src/main/java/org/wpilib/system/Tracer.java index 63091e6081..bdfdb9b609 100644 --- a/wpilibj/src/main/java/org/wpilib/system/Tracer.java +++ b/wpilibj/src/main/java/org/wpilib/system/Tracer.java @@ -18,7 +18,7 @@ import org.wpilib.driverstation.DriverStation; * which parts of an operation consumed the most time. */ public class Tracer { - private static final long kMinPrintPeriod = 1000000; // microseconds + private static final long MIN_PRINT_PERIOD = 1000000; // microseconds private long m_lastEpochsPrintTime; // microseconds private long m_startTime; // microseconds @@ -72,7 +72,7 @@ public class Tracer { */ public void printEpochs(Consumer output) { long now = RobotController.getMonotonicTime(); - if (now - m_lastEpochsPrintTime > kMinPrintPeriod) { + if (now - m_lastEpochsPrintTime > MIN_PRINT_PERIOD) { StringBuilder sb = new StringBuilder(); m_lastEpochsPrintTime = now; m_epochs.forEach( diff --git a/wpilibj/src/main/java/org/wpilib/system/Watchdog.java b/wpilibj/src/main/java/org/wpilib/system/Watchdog.java index df016e7cd7..1493c1bb65 100644 --- a/wpilibj/src/main/java/org/wpilib/system/Watchdog.java +++ b/wpilibj/src/main/java/org/wpilib/system/Watchdog.java @@ -25,7 +25,7 @@ import org.wpilib.util.WPIUtilJNI; */ public class Watchdog implements Closeable, Comparable { // Used for timeout print rate-limiting - private static final long kMinPrintPeriod = (long) 1e6; // μs + private static final long MIN_PRINT_PERIOD = (long) 1e6; // μs private double m_startTime; private double m_timeout; @@ -260,7 +260,7 @@ public class Watchdog implements Closeable, Comparable { Watchdog watchdog = m_watchdogs.poll(); double now = curTime * 1e-6; - if (now - watchdog.m_lastTimeoutPrint > kMinPrintPeriod) { + if (now - watchdog.m_lastTimeoutPrint > MIN_PRINT_PERIOD) { watchdog.m_lastTimeoutPrint = now; if (!watchdog.m_suppressTimeoutMessage) { DriverStation.reportWarning(