From cb4e165071ad56c4cf881f5221f02eeefde5de53 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 24 May 2018 12:49:23 -0400 Subject: 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 --- src/command.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/command.h') diff --git a/src/command.h b/src/command.h index e493c3ee..dd960cdf 100644 --- a/src/command.h +++ b/src/command.h @@ -61,14 +61,15 @@ enum { }; // command.c -char *command_parsef(char *p, char *maxend - , const struct command_parser *cp, uint32_t *args); -uint8_t command_encodef(char *buf, const struct command_encoder *ce - , va_list args); +uint8_t *command_parsef(uint8_t *p, uint8_t *maxend + , const struct command_parser *cp, uint32_t *args); +uint_fast8_t command_encodef(uint8_t *buf, const struct command_encoder *ce + , va_list args); void command_sendf(const struct command_encoder *ce, ...); -void command_add_frame(char *buf, uint8_t msglen); -int8_t command_find_block(char *buf, uint8_t buf_len, uint8_t *pop_count); -void command_dispatch(char *buf, uint8_t msglen); +void command_add_frame(uint8_t *buf, uint_fast8_t msglen); +int_fast8_t command_find_block(uint8_t *buf, uint_fast8_t buf_len + , uint_fast8_t *pop_count); +void command_dispatch(uint8_t *buf, uint_fast8_t msglen); // out/compile_time_request.c (auto generated file) extern const struct command_parser command_index[]; -- cgit v1.2.3-70-g09d2