mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-21 13:48:00 -06:00
command: Don't pass max_size to command_encodef()
The command_encodef() can read the max_size parameter directly from the 'struct command_encoder' passed into it. Also, there is no need to check that a message will fit in a buffer if the buffer is declared to be MESSAGE_MAX in size. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
f3da473285
commit
f8bd8b97be
7 changed files with 24 additions and 29 deletions
|
@ -94,14 +94,14 @@ error:
|
|||
|
||||
// Encode a message
|
||||
uint8_t
|
||||
command_encodef(char *buf, uint8_t buf_len
|
||||
, const struct command_encoder *ce, va_list args)
|
||||
command_encodef(char *buf, const struct command_encoder *ce, va_list args)
|
||||
{
|
||||
if (buf_len <= MESSAGE_MIN)
|
||||
uint8_t max_size = READP(ce->max_size);
|
||||
if (max_size <= MESSAGE_MIN)
|
||||
// Ack/Nak message
|
||||
return buf_len;
|
||||
return max_size;
|
||||
char *p = &buf[MESSAGE_HEADER_SIZE];
|
||||
char *maxend = &p[buf_len - MESSAGE_MIN];
|
||||
char *maxend = &p[max_size - MESSAGE_MIN];
|
||||
uint8_t num_params = READP(ce->num_params);
|
||||
const uint8_t *param_types = READP(ce->param_types);
|
||||
*p++ = READP(ce->msg_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue