Skip to content

Strip boilerplate and dead code - #1

Merged
killingerr merged 1 commit into
mainfrom
refactor-simplify
Oct 19, 2026
Merged

killingerr merged 1 commit into
mainfrom
refactor-simplify

Conversation

@killingerr

Copy link
Copy Markdown
Owner

Removes about 930 lines of boilerplate, defensive code and unused APIs. The CLI commands, DBus methods and signals, config file format, GUI layout, fan curve math and the Thelio Io control loop are unchanged.

Removed

  • FanCurveConfig::validate_persistence and the daemon's 3x save retry loop. Validation re-wrote the live config non-atomically after every save.
  • zbus_error_from_display and five unused error variants (FanCurveNotFound, InvalidFanPoint, PermissionDenied, DaemonNotRunning, Unknown).
  • Unused APIs: FanCurve::save_to_file/load_from_file, points_mut, get_point, FanDetector::read_fan_speed/fan_count, TempSource::id/from_id, and the nvidia_temperatures wrapper.
  • fan_detector's info-level logging on every control loop tick, plus the startup checks that only logged.

Simplified

  • FanCurveConfig::save_to_file creates the config directory, writes a temp file and renames it. The daemon and GUI both use it instead of their own copies.
  • Daemon DBus methods share save(), curve_index() and emit_curve_changed(). The built-in read-only checks are unchanged.
  • The CLI client is a single client::run(command) match. main.rs handles every subcommand in one match without boxing errors by hand.
  • cpu_temp and fan_detector keep the same detection logic in far less code.
  • duty_for_temperature interpolates over windows(2) and gives the same results.
  • The GUI's add-point and edit-point dialogs share one validation function and no longer parse their input twice.

Behavior changes

  • SetFanCurve took the config and curve index locks in the opposite order from every other method, which could deadlock. All methods now take them in the same order.
  • Saves write once, atomically, instead of retrying up to 3 times and then re-writing the file.
  • fan-curve-app with no subcommand prints "No command specified" without the "Unknown error:" prefix.
  • If /proc/cpuinfo has no vendor_id line, CPU temperature detection tries both coretemp and k10temp instead of failing.

Testing

  • cargo clippy --all-targets -- -D warnings is clean, and cargo test passes 47 tests, including the profiles and crash_recovery integration tests. Two unit tests were removed with the code they covered.
  • Not yet run on hardware. Before merging, check the daemon and GUI on the Thelio Mira r5 with the Io board.

…fig format and GUI.

Saving is now a single atomic write in FanCurveConfig::save_to_file, shared
by the daemon and GUI, replacing the daemon's retry loop and
validate_persistence, which re-wrote the live config non-atomically after
every save.

The daemon's DBus methods share one save and signal path and take their
locks in one order (SetFanCurve took them in the opposite order, which could
deadlock). The CLI client is a single match over subcommands, main.rs drops
its error-boxing map_errs, and fan_detector no longer logs at info level on
every control loop tick. Unused error variants, accessors and
TempSource::id/from_id are gone.
@killingerr
killingerr merged commit a0bd1ea into main Oct 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant