Skip to content

Commit da33b1d

Browse files
authored
[andino_firmware] Fix all pending pre-commit checks and style linting issues (#329)
Signed-off-by: Javier Balloffet <javier.balloffet@gmail.com>
1 parent c6e20d3 commit da33b1d

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

andino_firmware/CPPLINT.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
set noparent
2-
filter=-whitespace/line_length
2+
filter=-runtime/int,-whitespace/empty_if_body,-build/include_order
3+
linelength=120

andino_firmware/src/app/app.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6565
#include "andino/app/app.h"
6666

67+
#include <stdio.h>
68+
6769
#include <Adafruit_BNO055.h>
6870
#include <Adafruit_Sensor.h>
6971
#include <Arduino.h>
@@ -239,7 +241,7 @@ void App::cmd_set_pid_tuning_gains_cb(void* context, int argc, char** argv) {
239241
int pid_args[kSizePidArgs]{0, 0, 0, 0};
240242

241243
// Example: "u 30:20:10:50".
242-
strcpy(arg, argv[1]);
244+
snprintf(arg, sizeof(arg), "%s", argv[1]);
243245
char* p = arg;
244246
while ((str = strtok_r(p, ":", &p)) != NULL && i < kSizePidArgs) {
245247
pid_args[i] = atoi(str);

andino_firmware/src/app/shell.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
#include "andino/app/shell.h"
3131

32+
#include <stdio.h>
3233
#include <string.h>
3334

3435
namespace andino {
@@ -47,7 +48,7 @@ void Shell::register_command(const char* name, CommandCallback callback, void* c
4748
}
4849

4950
Command command;
50-
strcpy(command.name, name);
51+
snprintf(command.name, sizeof(command.name), "%s", name);
5152
command.callback = callback;
5253
command.context = context;
5354
commands_[commands_count_++] = command;
@@ -84,10 +85,11 @@ void Shell::process_input() {
8485
void Shell::parse_message() {
8586
char* argv[kCommandArgMax];
8687
int argc = 0;
88+
char* saveptr = nullptr;
8789

88-
argv[argc] = strtok(message_buffer_, " ");
90+
argv[argc] = strtok_r(message_buffer_, " ", &saveptr);
8991
while (argv[argc] != NULL && argc < (kCommandArgMax - 1)) {
90-
argv[++argc] = strtok(NULL, " ");
92+
argv[++argc] = strtok_r(NULL, " ", &saveptr);
9193
}
9294

9395
execute_callback(argc, argv);

0 commit comments

Comments
 (0)