aboutsummaryrefslogtreecommitdiffstats
path: root/src/linux/console.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-05-24 12:49:23 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-05-28 10:43:39 -0400
commitcb4e165071ad56c4cf881f5221f02eeefde5de53 (patch)
tree0d88bd5e3ebaf53526cda428eebf3d7ad61876bf /src/linux/console.c
parent2a55741ea883e6a9958a64c3463b4c3d60c21b63 (diff)
downloadkutter-cb4e165071ad56c4cf881f5221f02eeefde5de53.tar.gz
kutter-cb4e165071ad56c4cf881f5221f02eeefde5de53.tar.xz
kutter-cb4e165071ad56c4cf881f5221f02eeefde5de53.zip
command: Prefer uint8_t* for buffers; prefer uint8_fast_t for lengths
Prefer using 'uint8_t' buffers as it is too easy to run into C sign extension problems with 'char' buffers. Prefer using 'uint_fast8_t' for buffer lengths as gcc does a better job compiling them on 32bit mcus. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/linux/console.c')
-rw-r--r--src/linux/console.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/linux/console.c b/src/linux/console.c
index ba6223a0..a1086942 100644
--- a/src/linux/console.c
+++ b/src/linux/console.c
@@ -128,7 +128,7 @@ console_setup(char *name)
****************************************************************/
static struct task_wake console_wake;
-static char receive_buf[4096];
+static uint8_t receive_buf[4096];
static int receive_pos;
// Process any incoming commands
@@ -155,7 +155,7 @@ console_task(void)
// Find and dispatch message blocks in the input
int len = receive_pos + ret;
- uint8_t pop_count, msglen = len > MESSAGE_MAX ? MESSAGE_MAX : len;
+ uint_fast8_t pop_count, msglen = len > MESSAGE_MAX ? MESSAGE_MAX : len;
ret = command_find_block(receive_buf, msglen, &pop_count);
if (ret > 0)
command_dispatch(receive_buf, pop_count);
@@ -175,8 +175,8 @@ void
console_sendf(const struct command_encoder *ce, va_list args)
{
// Generate message
- char buf[MESSAGE_MAX];
- uint8_t msglen = command_encodef(buf, ce, args);
+ uint8_t buf[MESSAGE_MAX];
+ uint_fast8_t msglen = command_encodef(buf, ce, args);
command_add_frame(buf, msglen);
// Transmit message