mirror of
https://github.com/zmkfirmware/zmk.git
synced 2026-04-01 19:05:20 -05:00
refactor(splits): Minor cleanups to periph invocation
* Add strlcpy from public domain version. * Leverage strlcpy to detect truncation of behavior dev strs, and log. * Use `offsetof` for cleaner detection on peripheral side.
This commit is contained in:
committed by
Pete Johanson
parent
b8700eaaa1
commit
7430750428
@@ -51,8 +51,10 @@ static ssize_t split_svc_run_behavior(struct bt_conn *conn, const struct bt_gatt
|
||||
// We run if:
|
||||
// 1: We've gotten all the position/state/param data.
|
||||
// 2: We have a null terminated string for the behavior device label.
|
||||
const size_t behavior_dev_offset =
|
||||
offsetof(struct zmk_split_run_behavior_payload, behavior_dev);
|
||||
if ((end_addr > sizeof(struct zmk_split_run_behavior_data)) &&
|
||||
payload->behavior_dev[end_addr - sizeof(struct zmk_split_run_behavior_data) - 1] == '\0') {
|
||||
payload->behavior_dev[end_addr - behavior_dev_offset - 1] == '\0') {
|
||||
struct zmk_behavior_binding binding = {
|
||||
.param1 = payload->data.param1,
|
||||
.param2 = payload->data.param2,
|
||||
|
||||
Reference in New Issue
Block a user