mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-21 05:37:54 -06:00
command: Add command_decode_ptr() helper
Add a helper function to convert from a string buffer passed in the args[] parameter to an actual pointer. This avoids all the callers needing to perfrom pointer manipulation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
aaf3dc6ac3
commit
473828ca6a
10 changed files with 38 additions and 30 deletions
|
@ -15,6 +15,18 @@
|
|||
|
||||
static uint8_t next_sequence = MESSAGE_DEST;
|
||||
|
||||
static uint32_t
|
||||
command_encode_ptr(void *p)
|
||||
{
|
||||
return (size_t)p;
|
||||
}
|
||||
|
||||
void *
|
||||
command_decode_ptr(uint32_t v)
|
||||
{
|
||||
return (void*)(size_t)v;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* Binary message parsing
|
||||
|
@ -78,7 +90,7 @@ command_parsef(uint8_t *p, uint8_t *maxend
|
|||
if (p + len > maxend)
|
||||
goto error;
|
||||
*args++ = len;
|
||||
*args++ = (size_t)p;
|
||||
*args++ = command_encode_ptr(p);
|
||||
p += len;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue