mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-12 01:08:00 -06:00
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>
This commit is contained in:
parent
2a55741ea8
commit
cb4e165071
11 changed files with 71 additions and 78 deletions
|
@ -54,7 +54,7 @@ DECL_INIT(prescaler_init);
|
|||
|
||||
// Optimized crc16_ccitt for the avr processor
|
||||
uint16_t
|
||||
crc16_ccitt(char *buf, uint8_t len)
|
||||
crc16_ccitt(uint8_t *buf, uint_fast8_t len)
|
||||
{
|
||||
uint16_t crc = 0xFFFF;
|
||||
while (len--)
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
#include "command.h" // command_dispatch
|
||||
#include "sched.h" // DECL_INIT
|
||||
|
||||
static char receive_buf[MESSAGE_MAX];
|
||||
static uint8_t receive_pos;
|
||||
static uint8_t receive_buf[MESSAGE_MAX], receive_pos;
|
||||
|
||||
void
|
||||
usbserial_init(void)
|
||||
|
@ -51,7 +50,7 @@ void
|
|||
console_task(void)
|
||||
{
|
||||
console_check_input();
|
||||
uint8_t pop_count;
|
||||
uint_fast8_t pop_count;
|
||||
int8_t ret = command_find_block(receive_buf, receive_pos, &pop_count);
|
||||
if (ret > 0)
|
||||
command_dispatch(receive_buf, pop_count);
|
||||
|
@ -65,7 +64,7 @@ void
|
|||
console_sendf(const struct command_encoder *ce, va_list args)
|
||||
{
|
||||
// Generate message
|
||||
static char buf[MESSAGE_MAX];
|
||||
static uint8_t buf[MESSAGE_MAX];
|
||||
uint8_t msglen = command_encodef(buf, ce, args);
|
||||
command_add_frame(buf, msglen);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue