Skip to content

Commit

Permalink
use correct math for string length
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed Sep 30, 2023
1 parent 3351fc6 commit edc07de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ int version_func(CommandRouter *cmd, int argc, const char **argv) {
int serialnumber_func(CommandRouter *cmd, int argc, const char **argv) {
(void)argc;
(void)argv;
int i;
uint8_t i;
// https://github.com/PaulStoffregen/cores/pull/722
for (i=0; i < 10; i++) {
#pragma GCC diagnostic push
// https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
#pragma GCC diagnostic ignored "-Warray-bounds"
for (i=0; i < (usb_string_serial_number.bLength - 2) / sizeof(uint16_t); i++) {
cmd->buffer[i] = (char)usb_string_serial_number.wString[i];
}
#pragma GCC diagnostic pop
cmd->buffer[i] = '\0';
return 0;
}
Expand Down

0 comments on commit edc07de

Please sign in to comment.