Skip to content

Commit fe20d79

Browse files
TheRealHaoLiuclaude
andcommitted
Code review fixes for M5Stack Unit C6L
- Fix strdup memory leak in repeater UITask: use stack buffer instead - Remove redundant _display null check in companion UITask (already guarded at top of loop()) - Remove redundant build_src_filter exclusions in companion, repeater, and room_server envs (base config already handles them) - Remove repeater UITask.h copy: include original header directly via relative path instead of maintaining a duplicate - Remove unused -I flag for repeater subdirectory - Delete upstream UnitC6LBoard.h/cpp (replaced by M5StackUnitC6LBoard) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 713e87e commit fe20d79

File tree

6 files changed

+6
-94
lines changed

6 files changed

+6
-94
lines changed

variants/m5stack_unit_c6l/UnitC6LBoard.cpp

Lines changed: 0 additions & 49 deletions
This file was deleted.

variants/m5stack_unit_c6l/UnitC6LBoard.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

variants/m5stack_unit_c6l/companion/UITask.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void UITask::loop() {
109109

110110
if (_display->isOn()) {
111111
// Update marquee scroll
112-
if (_display != NULL && _node_prefs != NULL && millis() >= _scroll_next) {
112+
if (_node_prefs != NULL && millis() >= _scroll_next) {
113113
int nameW = _display->getTextWidth(_node_prefs->node_name);
114114
int w = _display->width();
115115
int maxScroll = nameW - w;

variants/m5stack_unit_c6l/platformio.ini

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ build_flags =
6767
; -D MESH_PACKET_LOGGING=1
6868
; -D MESH_DEBUG=1
6969
build_src_filter = ${m5stack_unit_c6l.build_src_filter}
70-
-<../variants/m5stack_unit_c6l/repeater/*.cpp>
7170
+<helpers/esp32/*.cpp>
7271
-<helpers/esp32/ESPNOWRadio.cpp>
7372
+<helpers/ui/SSD1306SPIDisplay.cpp>
@@ -82,7 +81,6 @@ lib_deps =
8281
[env:m5stack_unit_c6l_repeater]
8382
extends = m5stack_unit_c6l
8483
build_flags =
85-
-I variants/m5stack_unit_c6l/repeater
8684
${m5stack_unit_c6l.build_flags}
8785
; LoRa settings - must match other devices on your mesh
8886
-D LORA_FREQ=910.525
@@ -104,7 +102,6 @@ build_flags =
104102
-D DISPLAY_HEIGHT=48
105103
-D DISPLAY_ROTATION=2
106104
build_src_filter = ${m5stack_unit_c6l.build_src_filter}
107-
-<../variants/m5stack_unit_c6l/companion/*.cpp>
108105
+<helpers/ui/SSD1306SPIDisplay.cpp>
109106
+<../examples/simple_repeater>
110107
-<../examples/simple_repeater/UITask.cpp>
@@ -130,8 +127,6 @@ build_flags = ${m5stack_unit_c6l.build_flags}
130127
-D ROOM_PASSWORD='"hello"'
131128
-D MESH_PACKET_LOGGING=1
132129
build_src_filter = ${m5stack_unit_c6l.build_src_filter}
133-
-<../variants/m5stack_unit_c6l/companion/*.cpp>
134-
-<../variants/m5stack_unit_c6l/repeater/*.cpp>
135130
+<../examples/simple_room_server>
136131
lib_deps =
137132
${m5stack_unit_c6l.lib_deps}

variants/m5stack_unit_c6l/repeater/UITask.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// C6L-specific repeater UITask for 64x48 SSD1306 display
22
// Replaces examples/simple_repeater/UITask.cpp via build_src_filter
33

4-
#include "UITask.h"
4+
#include "../../../examples/simple_repeater/UITask.h"
55
#include <Arduino.h>
66
#include <helpers/CommonCLI.h>
77
#include <M5StackUnitC6LBoard.h>
@@ -26,11 +26,11 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi
2626
s_scroll_paused = true;
2727
_display->turnOn();
2828

29-
char *version = strdup(firmware_version);
29+
char version[16];
30+
strncpy(version, firmware_version, sizeof(version) - 1);
31+
version[sizeof(version) - 1] = '\0';
3032
char *dash = strchr(version, '-');
31-
if (dash) {
32-
*dash = 0;
33-
}
33+
if (dash) *dash = '\0';
3434
sprintf(_version_info, "%s (%s)", version, build_date);
3535
}
3636

variants/m5stack_unit_c6l/repeater/UITask.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)