From cd8a7517320b236836aa52fdabc09097f6c2f428 Mon Sep 17 00:00:00 2001 From: Richard Acayan Date: Wed, 21 Jun 2023 18:50:13 -0400 Subject: [PATCH] fastrpc: hexagonrpcd: listener: declare procedure array as pointer As an variable-length array within a struct, the procedure array is not included in the sizeof() macro and cannot be trivially copied. Declare it as a pointer to an array of procedures so the local fastrpc interface definitions have a predictable size. --- fastrpc/hexagonrpcd/apps_std.c | 124 +++++++++++++++++---------------- fastrpc/hexagonrpcd/listener.h | 2 +- fastrpc/hexagonrpcd/localctl.c | 10 +-- 3 files changed, 70 insertions(+), 66 deletions(-) diff --git a/fastrpc/hexagonrpcd/apps_std.c b/fastrpc/hexagonrpcd/apps_std.c index 23149f3..d48353c 100644 --- a/fastrpc/hexagonrpcd/apps_std.c +++ b/fastrpc/hexagonrpcd/apps_std.c @@ -404,68 +404,70 @@ err_free_pathname: return AEE_EFAILED; } +static const struct fastrpc_function_impl apps_std_procs[] = { + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { + .def = &apps_std_fflush_def, + .impl = apps_std_fflush, + }, + { + .def = &apps_std_fclose_def, + .impl = apps_std_fclose, + }, + { + .def = &apps_std_fread_def, + .impl = apps_std_fread, + }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { + .def = &apps_std_fseek_def, + .impl = apps_std_fseek, + }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { + .def = &apps_std_fopen_with_env_def, + .impl = apps_std_fopen_with_env, + }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { + .def = &apps_std_opendir_def, + .impl = apps_std_opendir, + }, + { + .def = &apps_std_closedir_def, + .impl = apps_std_closedir, + }, + { + .def = &apps_std_readdir_def, + .impl = apps_std_readdir, + }, + { .def = NULL, .impl = NULL, }, + { .def = NULL, .impl = NULL, }, + { + .def = &apps_std_stat_def, + .impl = apps_std_stat, + }, +}; + const struct fastrpc_interface apps_std_interface = { .name = "apps_std", .n_procs = 32, - .procs = { - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { - .def = &apps_std_fflush_def, - .impl = apps_std_fflush, - }, - { - .def = &apps_std_fclose_def, - .impl = apps_std_fclose, - }, - { - .def = &apps_std_fread_def, - .impl = apps_std_fread, - }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { - .def = &apps_std_fseek_def, - .impl = apps_std_fseek, - }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { - .def = &apps_std_fopen_with_env_def, - .impl = apps_std_fopen_with_env, - }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { - .def = &apps_std_opendir_def, - .impl = apps_std_opendir, - }, - { - .def = &apps_std_closedir_def, - .impl = apps_std_closedir, - }, - { - .def = &apps_std_readdir_def, - .impl = apps_std_readdir, - }, - { .def = NULL, .impl = NULL, }, - { .def = NULL, .impl = NULL, }, - { - .def = &apps_std_stat_def, - .impl = apps_std_stat, - }, - }, + .procs = apps_std_procs, }; diff --git a/fastrpc/hexagonrpcd/listener.h b/fastrpc/hexagonrpcd/listener.h index 908fa31..e042068 100644 --- a/fastrpc/hexagonrpcd/listener.h +++ b/fastrpc/hexagonrpcd/listener.h @@ -39,7 +39,7 @@ struct fastrpc_interface { const char *name; void *data; uint8_t n_procs; - struct fastrpc_function_impl procs[]; + const struct fastrpc_function_impl *procs; }; extern const struct fastrpc_interface localctl_interface; diff --git a/fastrpc/hexagonrpcd/localctl.c b/fastrpc/hexagonrpcd/localctl.c index 5cf42bc..d5f2904 100644 --- a/fastrpc/hexagonrpcd/localctl.c +++ b/fastrpc/hexagonrpcd/localctl.c @@ -99,11 +99,13 @@ static uint32_t localctl_close(void *data, return 0; } +static const struct fastrpc_function_impl localctl_procs[] = { + { .def = &remotectl_open_def, .impl = localctl_open, }, + { .def = &remotectl_close_def, .impl = localctl_close, }, +}; + const struct fastrpc_interface localctl_interface = { .name = "remotectl", .n_procs = 2, - .procs = { - { .def = &remotectl_open_def, .impl = localctl_open, }, - { .def = &remotectl_close_def, .impl = localctl_close, }, - }, + .procs = localctl_procs, };