aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-08-13 16:48:27 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-08-14 18:32:15 -0400
commitf8bd8b97bea9273d166efdc06c3a6a54fc24ffdb (patch)
tree4fc1819b36bd3151538dac06909fe83e841b6c86 /src/command.c
parentf3da473285557b0424d9b649bc67faa686d74393 (diff)
downloadkutter-f8bd8b97bea9273d166efdc06c3a6a54fc24ffdb.tar.gz
kutter-f8bd8b97bea9273d166efdc06c3a6a54fc24ffdb.tar.xz
kutter-f8bd8b97bea9273d166efdc06c3a6a54fc24ffdb.zip
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>
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/command.c b/src/command.c
index 3e5ef4c9..8780ae8a 100644
--- a/src/command.c
+++ b/src/command.c
@@ -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);