Skip to content

Commit bbdb92f

Browse files
committed
Add static analysis to CI and fix cppcheck findings
Signed-off-by: Javier Balloffet <javier.balloffet@gmail.com>
1 parent f73fd5b commit bbdb92f

5 files changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/mcu-ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ jobs:
5858
- name: Build application
5959
working-directory: ./andino_firmware
6060
run: pio run
61+
- name: Run static analysis
62+
working-directory: ./andino_firmware
63+
run: pio check --fail-on-defect=medium
6164
- name: Run unit tests
6265
working-directory: ./andino_firmware
6366
run: pio test --environment=desktop

andino_firmware/include/andino/app/app.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class App {
8686
left_pid_controller_(Constants::kPidKp, Constants::kPidKd, Constants::kPidKi,
8787
Constants::kPidKo, -Constants::kPwmMax, Constants::kPwmMax),
8888
right_pid_controller_(Constants::kPidKp, Constants::kPidKd, Constants::kPidKi,
89-
Constants::kPidKo, -Constants::kPwmMax, Constants::kPwmMax) {
89+
Constants::kPidKo, -Constants::kPwmMax, Constants::kPwmMax),
90+
shell_() {
9091
}
9192

9293
// Delete copy and move operations to enforce unique reference ownership.

andino_firmware/include/andino/app/shell.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ class Shell {
9898
CommandCallback default_callback_{nullptr};
9999

100100
/// Command registry.
101-
Command commands_[kCommandsMax];
101+
Command commands_[kCommandsMax]{};
102102

103103
/// Number of registered commands.
104104
size_t commands_count_{0};
105105

106106
/// Command prompt message.
107-
char message_buffer_[kCommandPromptLengthMax];
107+
char message_buffer_[kCommandPromptLengthMax]{};
108108

109109
/// Command prompt message index.
110110
int message_index_{0};

andino_firmware/include/andino/drivers/encoder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ class Encoder {
127127
static const InterruptIn::InterruptCallback kCallbacks[kInstancesMax];
128128

129129
/// Static wrapper that redirects to the first instance callback method.
130+
// cppcheck-suppress unusedPrivateFunction
131+
// Referenced only through the kCallbacks function pointer table, which cppcheck can't trace.
130132
static void callback_0();
131133

132134
/// Static wrapper that redirects to the second instance callback method.
135+
// cppcheck-suppress unusedPrivateFunction
133136
static void callback_1();
134137

135138
/// Channels interrupt callback.

andino_firmware/src/app/shell.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void Shell::parse_message() {
9090
char* saveptr = nullptr;
9191

9292
argv[argc] = strtok_r(message_buffer_, " ", &saveptr);
93-
while (argv[argc] != NULL && argc < (kCommandArgMax - 1)) {
93+
while (argc < (kCommandArgMax - 1) && argv[argc] != NULL) {
9494
argv[++argc] = strtok_r(NULL, " ", &saveptr);
9595
}
9696

0 commit comments

Comments
 (0)