From 147e51c125f49310cb22d61cb78f10a921cbbcb0 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Sun, 22 Oct 2023 21:16:49 +0100 Subject: [PATCH] Com: Make the comment length explicit sendComment cannot send more than 62 bytes, as limited by the HID report. Sending more is prevented by vsnprintf, but change the function signature to make it explicit that the array passed to it should be at most 62 bytes. --- .gitignore | 2 +- include/Com.h | 2 +- src/Com.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b43bfca..921d40b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .pio -.idea +**/.idea diff --git a/include/Com.h b/include/Com.h index 3fa4f4c..a5e251a 100644 --- a/include/Com.h +++ b/include/Com.h @@ -14,7 +14,7 @@ */ namespace Com { void sendFigUpdate(int8_t event); - void sendComment(const char* message, ...); + void sendComment(const char message[62], ...); } #endif //JIN_BARBAPAPA_COM_H diff --git a/src/Com.cpp b/src/Com.cpp index 1513b3a..8fa4377 100644 --- a/src/Com.cpp +++ b/src/Com.cpp @@ -28,7 +28,7 @@ namespace Com { flushBuffer(); } - void sendComment(const char *message, ...) { + void sendComment(const char message[62], ...) { va_list args; va_start(args, message); buffer[0] = '#';