Skip to content

Adopt shared UniqueFd, per-config LTO, and tidy hygiene - #20

Merged
jwinarske merged 1 commit into
mainfrom
jw/optional-improvements
Jul 12, 2026
Merged

Adopt shared UniqueFd, per-config LTO, and tidy hygiene#20
jwinarske merged 1 commit into
mainfrom
jw/optional-improvements

Conversation

@jwinarske

Copy link
Copy Markdown
Owner

Bundles the well-scoped improvements suggested by the sibling-repo review (drm-cxx, wayland-cxx-scanner). Builds clean (gcc 16 / clang 19, all 96 targets), passes clang-format --Werror, no new clang-tidy findings.

UniqueFd: hoist + upgrade

  • Moved UniqueFd from src/bluez/hidraw.hpp into a shared src/utils/unique_fd.h.
  • Added a default constructor (so it can be a plain member without an in-place init), explicit operator bool(), [[nodiscard]] release(), reset(fd = -1), and borrow-vs-own via UniqueFd::Borrow(fd) — a borrowed fd is never closed. This is the escape hatch for descriptors whose lifetime is owned elsewhere, e.g. an fd received over D-Bus as sdbus::UnixFd, where closing here would double-close.
  • The three controller input_reader.h files now include unique_fd.h directly; the owner headers that inherit from Hidraw include hidraw.hpp directly instead of relying on a transitive include.

Per-config LTO

  • LTO is now enabled per configuration via CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG> for Release / MinSizeRel / RelWithDebInfo, set once in the root CMakeLists.txt.
  • Removed the 24 per-target set_property(... INTERPROCEDURAL_OPTIMIZATION TRUE) blocks that forced LTO on every build type, including Debug.
  • Verified: a Debug configure emits -flto in 0 TUs; a Release configure emits it in all 63. Optimized builds (CI Release, default MinSizeRel) are unchanged.

clang-tidy hygiene

  • Added WarningsAsErrors: '*' and a HeaderFilterRegex that excludes both third_party and the generated src/proxy/ headers, so a local clang-tidy run matches what CI enforces. CI still passes its own -header-filter / -warnings-as-errors on the command line, so its behavior is unchanged.

CI + housekeeping

  • Pinned cache-apt-pkgs-action and ccache-action to commit SHAs (# v1 retained as a comment), matching how actions/* are pinned in this repo.
  • Removed the generated tidy-results-log.txt / tidy-results-suggested-fixes.txt and added tidy-results-*.txt to .gitignore.

Deliberately not included

The two larger architectural suggestions — migrating fallible device I/O to std::expected<T, std::error_code>, and a uniform fd() + set_handler() + dispatch() pollable-source contract to replace the per-client worker-thread/mutex pattern — are broad refactors of the error and threading models. They belong in their own focused change rather than folded in here.

- Hoist UniqueFd out of src/bluez/hidraw.hpp into src/utils/unique_fd.h so any
  client can reuse it. Add a default constructor, explicit operator bool,
  release(), reset(), and borrow-vs-own semantics (Borrow()) so a descriptor
  owned elsewhere - e.g. one received over D-Bus as sdbus::UnixFd - is not
  closed here. Include it directly where used, and pull hidraw.hpp into the
  owner headers that inherit from Hidraw rather than relying on a transitive
  include.
- Enable LTO per configuration via CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG>
  for Release/MinSizeRel/RelWithDebInfo, and drop the per-target set_property
  blocks that forced it on every build type. Debug builds no longer pay for
  LTO; optimized builds are unchanged.
- clang-tidy: set WarningsAsErrors and a HeaderFilterRegex that excludes both
  third_party and the generated src/proxy headers, so a local run matches CI.
- Pin cache-apt-pkgs-action and ccache-action to commit SHAs.
- Remove the generated tidy-results-*.txt artifacts and ignore them.

Signed-off-by: Joel Winarske <joel.winarske@linux.com>
@jwinarske
jwinarske merged commit 6836869 into main Jul 12, 2026
6 checks passed
@jwinarske
jwinarske deleted the jw/optional-improvements branch July 12, 2026 21:18
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