Skip to content

Commit abcf8c0

Browse files
committed
Code cleanup
1 parent 279eb9a commit abcf8c0

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

.clang-format

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,9 @@ IndentWrappedFunctionNames: true
125125
InsertNewlineAtEOF: true
126126
InsertTrailingCommas: Wrapped
127127
IntegerLiteralSeparator:
128-
Binary: 4
129-
BinaryMinDigits: 9
130-
Decimal: 3
131-
DecimalMinDigits: 5
132-
Hex: 2
133-
HexMinDigits: 9
128+
Binary: 0
129+
Decimal: 0
130+
Hex: 0
134131
KeepEmptyLinesAtEOF: false
135132
KeepEmptyLinesAtTheStartOfBlocks: false
136133
LambdaBodyIndentation: OuterScope

include/Checksum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ namespace OpenShock::Checksum {
4444
*/
4545
constexpr uint8_t ReverseNibble(uint8_t b)
4646
{
47-
return (0xF7'B3'D5'91'E6'A2'C4'80 >> (b * 4)) & 0xF; // Trust me bro
47+
return (0xF7B3D591E6A2C480ull >> (b * 4)) & 0xF; // Trust me bro
4848
}
4949

5050
/**
5151
* Make sure the uint8 only has its high bits (0x0F) set before using this function
5252
*/
5353
constexpr uint8_t ReverseInverseNibble(uint8_t b)
5454
{
55-
return (0x08'4C'2A'6E'19'5D'3B'7F >> (b * 4)) & 0xF; // Trust me bro
55+
return (0x084C2A6E195D3B7Full >> (b * 4)) & 0xF; // Trust me bro
5656
}
5757
} // namespace OpenShock::Checksum
5858

include/Common.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@
4545
"Let it be known that Arduino hath finally been cast aside in favor of the noble ESP-IDF! I beseech thee, kind sir or madam, wouldst thou kindly partake in the honors of expunging 'arduino-esp32' from yonder useragent aloft, and in its stead, bestow the illustrious 'ESP-IDF'?"
4646
#endif
4747

48-
#if __cplusplus >= 202'302L
48+
#if __cplusplus >= 202302L
4949
#warning "C++23 compiler detected"
50-
#elif __cplusplus >= 202'002L
50+
#elif __cplusplus >= 202002L
5151
#warning "C++20 compiler detected"
52-
#elif __cplusplus >= 201'703L
52+
#elif __cplusplus >= 201703L
5353
// C++17 :3
54-
#elif __cplusplus >= 201'402L
54+
#elif __cplusplus >= 201402L
5555
#error "C++14 compiler detected, OpenShock requires a C++17 compliant compiler"
56-
#elif __cplusplus >= 201'103L
56+
#elif __cplusplus >= 201103L
5757
#error "C++11 compiler detected, OpenShock requires a C++17 compliant compiler"
58-
#elif __cplusplus >= 199'711L
58+
#elif __cplusplus >= 199711L
5959
#error "C++98 compiler detected, OpenShock requires a C++17 compliant compiler"
6060
#elif __cplusplus == 1
6161
#error "Pre-C++98 compiler detected, OpenShock requires a C++17 compliant compiler"

include/serial/command_handlers/CommandEntry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace OpenShock::Serial {
1616

1717
class CommandEntry {
1818
public:
19-
CommandEntry(std::string_view description, CommandHandler commandHandler);
20-
CommandEntry(std::string_view name, std::string_view description, CommandHandler commandHandler);
19+
CommandEntry(std::string_view description, CommandHandler commandHandler) noexcept;
20+
CommandEntry(std::string_view name, std::string_view description, CommandHandler commandHandler) noexcept;
2121

2222
inline std::string_view name() const { return m_name; }
2323
inline std::string_view description() const { return m_description; }

src/serial/command_handlers/CommandEntry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
using namespace OpenShock::Serial;
44

5-
CommandEntry::CommandEntry(std::string_view description, CommandHandler commandHandler)
5+
CommandEntry::CommandEntry(std::string_view description, CommandHandler commandHandler) noexcept
66
: m_description(description)
77
, m_commandHandler(commandHandler)
88
{
99
}
1010

11-
CommandEntry::CommandEntry(std::string_view name, std::string_view description, CommandHandler commandHandler)
11+
CommandEntry::CommandEntry(std::string_view name, std::string_view description, CommandHandler commandHandler) noexcept
1212
: m_name(name)
1313
, m_description(description)
1414
, m_commandHandler(commandHandler)

src/wifi/WiFiManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ std::vector<WiFiNetwork>::iterator _findNetwork(std::function<bool(WiFiNetwork&)
8686
}
8787
std::vector<WiFiNetwork>::iterator _findNetworkBySSID(const char* ssid, bool sortByAttractivity = true)
8888
{
89-
return _findNetwork([ssid](const WiFiNetwork& net) { return strcmp(net.ssid, ssid) == 0; }, sortByAttractivity);
89+
return _findNetwork([ssid](const WiFiNetwork& net) noexcept { return strcmp(net.ssid, ssid) == 0; }, sortByAttractivity);
9090
}
9191
std::vector<WiFiNetwork>::iterator _findNetworkByBSSID(const uint8_t (&bssid)[6])
9292
{
93-
return _findNetwork([bssid](const WiFiNetwork& net) { return memcmp(net.bssid, bssid, sizeof(bssid)) == 0; }, false);
93+
return _findNetwork([bssid](const WiFiNetwork& net) noexcept { return memcmp(net.bssid, bssid, sizeof(bssid)) == 0; }, false);
9494
}
9595
std::vector<WiFiNetwork>::iterator _findNetworkByCredentialsID(uint8_t credentialsID, bool sortByAttractivity = true)
9696
{
97-
return _findNetwork([credentialsID](const WiFiNetwork& net) { return net.credentialsID == credentialsID; }, sortByAttractivity);
97+
return _findNetwork([credentialsID](const WiFiNetwork& net) noexcept { return net.credentialsID == credentialsID; }, sortByAttractivity);
9898
}
9999

100100
bool _markNetworkAsAttempted(const uint8_t (&bssid)[6])
@@ -564,7 +564,7 @@ bool WiFiManager::GetConnectedNetwork(OpenShock::WiFiNetwork& network)
564564
return false;
565565
}
566566

567-
auto it = _findNetwork([](const WiFiNetwork& net) { return net.credentialsID == s_connectedCredentialsID; });
567+
auto it = _findNetwork([](const WiFiNetwork& net) noexcept { return net.credentialsID == s_connectedCredentialsID; });
568568
if (it == s_wifiNetworks.end()) {
569569
return false;
570570
}

0 commit comments

Comments
 (0)