Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,12 @@ clang-analyzer-security.*,
cppcoreguidelines-pro-bounds-*,
cppcoreguidelines-pro-type-reinterpret-cast'

# Promote all enabled checks to errors so a local `clang-tidy` run fails the
# same way CI does (CI passes -warnings-as-errors='*' on the command line).
WarningsAsErrors: '*'

# Lint this project's own headers, but not third-party submodules or the
# generated proxy headers under src/proxy/.
HeaderFilterRegex: '^(?!.*(third_party|/proxy/)).*$'


10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install dependencies
# awalsh128/cache-apt-pkgs-action — caches the .deb set between runs.
# Tag-pinned to match the convention used in the sibling drm-cxx repo.
uses: awalsh128/cache-apt-pkgs-action@v1
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1
with:
packages: cmake ninja-build libudev-dev libsystemd-dev pkg-config gcc-14 g++-14
version: 1.0
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install clang-format
uses: awalsh128/cache-apt-pkgs-action@v1
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1
with:
packages: clang-format
version: 1.0
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:

- name: Install dependencies
# Repo added above, so the cache action can resolve the LLVM packages.
uses: awalsh128/cache-apt-pkgs-action@v1
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1
with:
packages: >-
clang-19 clang-tidy-19 llvm-19 llvm-19-dev lld-19
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
'deb https://apt.llvm.org/noble/ llvm-toolchain-noble-19 main'

- name: Install dependencies
uses: awalsh128/cache-apt-pkgs-action@v1
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1
with:
packages: "cmake ninja-build libudev-dev libsystemd-dev pkg-config ${{ matrix.compiler.name == 'gcc-14' && 'gcc-14 g++-14' || 'clang-19 llvm-19 llvm-19-dev lld-19 libc++-19-dev libc++abi-19-dev' }}"
version: 1.0
Expand All @@ -217,7 +217,7 @@ jobs:
# Caches object files across runs. The pinned submodules
# (sdbus-c++, spdlog, glaze) don't change, so their compiles hit the
# cache after the first run. Tag-pinned per the drm-cxx convention.
uses: hendrikmuhs/ccache-action@v1
uses: hendrikmuhs/ccache-action@5ebbd400eff9e74630f759d94ddd7b6c26299639 # v1
with:
key: ${{ matrix.compiler.name }}

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ _codeql_detected_source_root

.vscode/

clang-format-files
clang-format-files
# clang-tidy run artifacts
tidy-results-*.txt
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ if (ENABLE_LTO)
)
if (IPO_SUPPORT_RESULT)
message(STATUS "IPO .................... supported")
# Enable LTO for optimized configurations only. Debug builds skip it
# so local iteration stays fast; Release/MinSizeRel/RelWithDebInfo
# (the CI and default build types) keep it. Setting these before the
# add_subdirectory() calls below makes every target inherit them, so
# no per-target set_property() is needed.
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON)
else ()
message(STATUS "IPO .................... not supported: ${IPO_SUPPORT_OUTPUT}")
endif ()
Expand Down
3 changes: 0 additions & 3 deletions src/avahi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ target_link_libraries(avahi_server_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET avahi_server_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS avahi_server_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/bluez/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(bluez_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET bluez_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS bluez_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
Expand Down
39 changes: 1 addition & 38 deletions src/bluez/hidraw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,47 +33,10 @@
#include <cctype>

#include "../utils/logging.h"
#include "../utils/unique_fd.h"

#include "hexdump.hpp"

/// RAII wrapper for a POSIX file descriptor.
/// Automatically closes the fd when it goes out of scope, preventing leaks
/// on every error-path break/return/exception.
struct UniqueFd {
explicit UniqueFd(const int fd) noexcept : fd_(fd) {}

~UniqueFd() {
if (fd_ >= 0) {
::close(fd_);
}
}

// Non-copyable, movable
UniqueFd(const UniqueFd&) = delete;
UniqueFd& operator=(const UniqueFd&) = delete;

UniqueFd(UniqueFd&& other) noexcept : fd_(other.fd_) { other.fd_ = -1; }
UniqueFd& operator=(UniqueFd&& other) noexcept {
if (this != &other) {
if (fd_ >= 0) {
::close(fd_);
}
fd_ = other.fd_;
other.fd_ = -1;
}
return *this;
}

/// Returns true if the fd is valid (>= 0).
[[nodiscard]] bool valid() const noexcept { return fd_ >= 0; }

/// Returns the raw file descriptor.
[[nodiscard]] int get() const noexcept { return fd_; }

private:
int fd_;
};

class Hidraw {
public:
Hidraw() = default;
Expand Down
3 changes: 0 additions & 3 deletions src/bluez/horipad_steam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ target_link_libraries(horipad_steam_client
spdlog::spdlog
PkgConfig::UDEV
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET horipad_steam_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS horipad_steam_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
2 changes: 1 addition & 1 deletion src/bluez/horipad_steam/input_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <atomic>
#include <thread>

#include "../hidraw.hpp"
#include "../../utils/unique_fd.h"
#include "horipad_stream_01ab_0196.h"

class InputReader {
Expand Down
3 changes: 0 additions & 3 deletions src/bluez/ps5_dual_sense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ target_link_libraries(dual_sense_client
spdlog::spdlog
PkgConfig::UDEV
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET dual_sense_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS dual_sense_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
2 changes: 1 addition & 1 deletion src/bluez/ps5_dual_sense/input_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <atomic>
#include <thread>

#include "../hidraw.hpp"
#include "../../utils/unique_fd.h"
#include "dual_sense_0ce6.h"

class InputReader {
Expand Down
3 changes: 0 additions & 3 deletions src/bluez/xbox_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ target_link_libraries(xbox_controller_client
spdlog::spdlog
PkgConfig::UDEV
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET xbox_controller_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS xbox_controller_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
2 changes: 1 addition & 1 deletion src/bluez/xbox_controller/input_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <atomic>
#include <thread>

#include "../hidraw.hpp"
#include "../../utils/unique_fd.h"
#include "xbox_controller_02fd.h"

class InputReader {
Expand Down
1 change: 1 addition & 0 deletions src/bluez/xbox_controller/xbox_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "../../upower/upower_client.h"
#include "../adapter1.h"
#include "../device1.h"
#include "../hidraw.hpp"
#include "../input1.h"
#include "../udev_monitor.hpp"

Expand Down
3 changes: 0 additions & 3 deletions src/connman/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ target_link_libraries(connman_client
spdlog::spdlog
)

if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET connman_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS connman_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/flatpak/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(flatpak_system_helper_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET flatpak_system_helper_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS flatpak_system_helper_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/fwupd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(fwupd_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET fwupd_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS fwupd_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/geoclue2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ target_link_libraries(geoclue2_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET geoclue2_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS geoclue2_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/hostname1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(hostname1_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET hostname1_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS hostname1_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/locale1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(locale1_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET locale1_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS locale1_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/login1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(login1_manager_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET login1_manager_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS login1_manager_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/network1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ target_link_libraries(network1_client
spdlog::spdlog
)

if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET network1_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS network1_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/packagekit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ target_link_libraries(packagekit_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET packagekit_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS packagekit_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/realtimekit1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(realtimekit1_manager_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET realtimekit1_manager_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS realtimekit1_manager_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/resolve1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(resolve1_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET resolve1_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS resolve1_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/systemd1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ target_link_libraries(systemd1_client
spdlog::spdlog
)

if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET systemd1_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS systemd1_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/timedate1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(timedate1_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET timedate1_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS timedate1_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
3 changes: 0 additions & 3 deletions src/timesync1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(timesync1_manager_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET timesync1_manager_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS timesync1_manager_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
6 changes: 0 additions & 6 deletions src/udisks2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ target_link_libraries(udisks2_client
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET udisks2_client PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS udisks2_client
RUNTIME DESTINATION share/sdbus-cpp-examples)
Expand All @@ -27,9 +24,6 @@ target_link_libraries(udisks2_monitor_daemon
sdbus-c++
spdlog::spdlog
)
if (ENABLE_LTO AND IPO_SUPPORT_RESULT)
set_property(TARGET udisks2_monitor_daemon PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()

install(TARGETS udisks2_monitor_daemon
RUNTIME DESTINATION share/sdbus-cpp-examples)
Loading
Loading