From caff96922e6e45c9755cefecfafce7560b6eb694 Mon Sep 17 00:00:00 2001 From: Teo-CD 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 b4f376f..8165ebe 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 bd33269..adafc82 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] = '#';