From 0ca7473ba916bbd0191d13e6856d4e8f320a4230 Mon Sep 17 00:00:00 2001 From: Richard Acayan Date: Thu, 26 Jan 2023 21:54:10 -0500 Subject: [PATCH] fastrpc: listener: add interface count Other compilation units do not know how many elements there are in the array. Add a number with the number of interfaces so other compilation units can iterate over every interface. --- fastrpc/listener.c | 7 +++++-- fastrpc/listener.h | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fastrpc/listener.c b/fastrpc/listener.c index 10d3a46..d551ae9 100644 --- a/fastrpc/listener.c +++ b/fastrpc/listener.c @@ -19,6 +19,7 @@ * along with this program. If not, see . */ +#include #include #include "fastrpc.h" @@ -29,6 +30,9 @@ const struct fastrpc_interface *fastrpc_listener_interfaces[] = { }; +size_t fastrpc_listener_n_interfaces = sizeof(fastrpc_listener_interfaces) + / sizeof(*fastrpc_listener_interfaces); + static int adsp_listener_init2(int fd) { return fastrpc2(&adsp_listener_init2_def, fd, ADSP_LISTENER_HANDLE); @@ -192,8 +196,7 @@ static int invoke_requested_procedure(uint32_t handle, uint8_t out_count; int ret; - if (handle >= sizeof(fastrpc_listener_interfaces) - / sizeof(*fastrpc_listener_interfaces) + if (handle >= fastrpc_listener_n_interfaces || REMOTE_SCALARS_METHOD(sc) >= fastrpc_listener_interfaces[handle]->n_procs) return -1; diff --git a/fastrpc/listener.h b/fastrpc/listener.h index fef0379..c8262b5 100644 --- a/fastrpc/listener.h +++ b/fastrpc/listener.h @@ -1,6 +1,8 @@ #ifndef LISTENER_H #define LISTENER_H +#include + #include "fastrpc.h" #include "iobuffer.h" @@ -17,6 +19,7 @@ struct fastrpc_interface { }; extern const struct fastrpc_interface *fastrpc_listener_interfaces[]; +extern size_t fastrpc_listener_n_interfaces; int run_fastrpc_listener(int fd);