Skip to content

Commit ec55f49

Browse files
committed
Fix and prevent One Definition Rule (ODR) issues
1 parent 00eab49 commit ec55f49

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ build_flags =
141141
-DGIT_COMMIT_HASH='"Homebrew"'
142142
-DFASTLED_RMT_BUILTIN_DRIVER=1 ; https://github.com/FastLED/FastLED/blob/67436be11fc3b7be611cdf9011f31c4f76817741/src/platforms/esp/32/rmt_4/idf4_clockless_rmt_esp32.h#L25-L33
143143
; This setting let RF Spectrum to work with LED interface with FastLED on ESP32-S3
144-
144+
-Werror=odr ; Treats One Definition Rule violations as errors in LTO builds
145145
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096 ; Reduces stack size for Async TCP to save memory
146146
-DCONFIG_ASYNC_TCP_RUNNING_CORE=1 ;
147147
-DCONFIG_ASYNC_TCP_USE_WDT=0 ; Disables the Watchdog timer on Async TCP, to avoid restartings during file uploads

src/modules/badusb_ble/ducky_typer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum DuckyCommandType {
3434
DuckyCommandType_DefaultStringDelay
3535
};
3636

37-
struct DuckyCommand {
37+
struct DuckyCommandLookup {
3838
const char *command;
3939
char key;
4040
DuckyCommandType type;
@@ -62,7 +62,7 @@ const DuckyCombination duckyComb[]{
6262
{"SYSREQ", KEY_LEFT_ALT, KEY_PRINT_SCREEN, 0 }
6363
};
6464

65-
const DuckyCommand duckyCmds[]{
65+
const DuckyCommandLookup duckyCmds[]{
6666
{"REM", 0, DuckyCommandType_Comment },
6767
{"//", 0, DuckyCommandType_Comment },
6868
{"STRING", 0, DuckyCommandType_Print },
@@ -634,8 +634,8 @@ void key_input(FS fs, String bad_script, HIDInterface *_hid) {
634634
uint16_t i;
635635
uint16_t repeatCount = RepeatTmp.toInt();
636636
for (i = 0; i < repeatCount; i++) {
637-
DuckyCommand *PriCmd = findDuckyCommand(Cmd);
638-
DuckyCommand *ArgCmd = findDuckyCommand(Argument.c_str());
637+
DuckyCommandLookup *PriCmd = findDuckyCommand(Cmd);
638+
DuckyCommandLookup *ArgCmd = findDuckyCommand(Argument.c_str());
639639

640640
if (PriCmd != nullptr) {
641641
// REM comment lines are processed here
@@ -986,9 +986,9 @@ void MediaCommands(HIDInterface *hid, bool ble) {
986986
returnToMenu = true;
987987
}
988988

989-
DuckyCommand *findDuckyCommand(const char *cmd) {
989+
DuckyCommandLookup *findDuckyCommand(const char *cmd) {
990990
for (auto &cmds : duckyCmds) {
991-
if (strcmp(cmd, cmds.command) == 0) { return const_cast<DuckyCommand *>(&cmds); }
991+
if (strcmp(cmd, cmds.command) == 0) { return const_cast<DuckyCommandLookup *>(&cmds); }
992992
}
993993
return nullptr;
994994
}

src/modules/badusb_ble/ducky_typer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern HIDInterface *hid_ble;
1818
extern uint8_t _Ask_for_restart;
1919

2020
struct DuckyCommand;
21+
struct DuckyCommandLookup;
2122
struct DuckyCombination;
2223

2324
// Start badUSB or badBLE ducky runner
@@ -38,7 +39,7 @@ void ducky_keyboard(HIDInterface *&hid, bool ble = false);
3839
// Send media commands through BLE or USB HID
3940
void MediaCommands(HIDInterface *hid, bool ble = false);
4041

41-
DuckyCommand *findDuckyCommand(const char *cmd);
42+
DuckyCommandLookup *findDuckyCommand(const char *cmd);
4243
DuckyCombination *findDuckyCombination(const char *cmd);
4344

4445
void sendAltChar(HIDInterface *hid, uint8_t charCode);

0 commit comments

Comments
 (0)