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:
@@ -181,7 +181,7 @@ command_neopixel_update(uint32_t *args)
|
||||
struct neopixel_s *n = oid_lookup(oid, command_config_neopixel);
|
||||
uint_fast16_t pos = args[1];
|
||||
uint_fast8_t data_len = args[2];
|
||||
uint8_t *data = (void*)(size_t)args[3];
|
||||
uint8_t *data = command_decode_ptr(args[3]);
|
||||
if (pos & 0x8000 || pos + data_len > n->data_size)
|
||||
shutdown("Invalid neopixel update command");
|
||||
memcpy(&n->data[pos], data, data_len);
|
||||
|
||||
Reference in New Issue
Block a user