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.
This commit is contained in:
Richard Acayan
2023-01-26 21:54:10 -05:00
parent 18f1b25106
commit 0ca7473ba9
2 changed files with 8 additions and 2 deletions

View File

@@ -19,6 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stddef.h>
#include <stdio.h>
#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;

View File

@@ -1,6 +1,8 @@
#ifndef LISTENER_H
#define LISTENER_H
#include <stddef.h>
#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);