Skip to content

Commit

Permalink
windows/serialInterface: Fixed some clang-tidy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed Jan 14, 2024
1 parent 33192d1 commit b6d81e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/include/windows/serialInterface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct serialInterface_t
private:
HANDLE device{INVALID_HANDLE_VALUE};

void handleDeviceError(const std::string_view operation) noexcept;
void handleDeviceError(std::string_view operation) noexcept;

public:
serialInterface_t() noexcept = default;
Expand Down
14 changes: 13 additions & 1 deletion src/windows/serialInterface.cxx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2023 1BitSquared <[email protected]>
// SPDX-FileCopyrightText: 2023a-2024 1BitSquared <[email protected]>
// SPDX-FileContributor: Written by Rachel Mant <[email protected]>
#include <cstdint>
#include <cstddef>
#include <array>
#include <string>
#include <string_view>
#include <fmt/format.h>
#include <substrate/console>
#include "windows/serialInterface.hxx"
#include "usbDevice.hxx"
#include "bmp.hxx"

using substrate::console;
Expand Down Expand Up @@ -65,6 +71,7 @@ struct hklmRegistryKey_t
}()
} { }

// NOLINTNEXTLINE(modernize-use-equals-default)
~hklmRegistryKey_t() noexcept
{
// Close the key if we're destructing a valid object that holds a handle to one
Expand All @@ -75,6 +82,7 @@ struct hklmRegistryKey_t
[[nodiscard]] bool valid() const noexcept { return handle != INVALID_HANDLE_VALUE; }

// Reads the string key `keyName` from the registry
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
[[nodiscard]] std::string readStringKey(std::string_view keyName) const
{
DWORD valueLength{0U};
Expand Down Expand Up @@ -213,12 +221,14 @@ serialInterface_t::serialInterface_t(const usbDevice_t &usbDevice) : device
static_cast<void>(ReadFile(device, serialState.data(), serialState.size(), nullptr, nullptr));
}

// NOLINTNEXTLINE(modernize-use-equals-default)
serialInterface_t::~serialInterface_t() noexcept
{
if (device != INVALID_HANDLE_VALUE)
CloseHandle(device);
}

// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
void serialInterface_t::handleDeviceError(const std::string_view operation) noexcept
{
// Get the last error that occured
Expand All @@ -243,6 +253,7 @@ void serialInterface_t::swap(serialInterface_t &interface) noexcept
std::swap(device, interface.device);
}

// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
void serialInterface_t::writePacket(const std::string_view &packet) const
{
console.debug("Remote write: "sv, packet);
Expand All @@ -257,6 +268,7 @@ void serialInterface_t::writePacket(const std::string_view &packet) const
}
}

// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
std::string serialInterface_t::readPacket() const
{
std::array<char, bmp_t::maxPacketSize + 1U> packet{};
Expand Down

0 comments on commit b6d81e7

Please sign in to comment.