From 4cad95ec182ab9f3d28f37cfab9fb28ccb596cd7 Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Tue, 21 Feb 2023 14:32:42 +0100 Subject: actions: change pointer to offset --- actions.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'actions.c') diff --git a/actions.c b/actions.c index 6a7f55c..bb603af 100644 --- a/actions.c +++ b/actions.c @@ -211,14 +211,12 @@ int do_actions(void *data, struct action actions[], unsigned int n_actions, int resp.id = id; resp.flags = 0; resp.error = 0; - if (actions[i].ret.type == IMMEDIATE) { + if (actions[i].ret.type == IMMEDIATE) resp.val = actions[i].ret.value; - } else if (actions[i].ret.value_p != NULL) { - resp.val = *(actions[i].ret.value_p); - } else { - fprintf(stderr, "empty reference for the return value"); - return -1; - } + else + memcpy(&resp.val, (uint16_t *)data + + actions[i].ret.value_off, + sizeof(resp.val)); if (send_target(&resp, notifyfd) == -1) return -1; -- cgit v1.2.3