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.
This commit is contained in:
Richard Acayan
2023-06-21 18:50:13 -04:00
parent 9946564fe9
commit cd8a751732
3 changed files with 70 additions and 66 deletions

View File

@@ -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,
};

View File

@@ -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;

View File

@@ -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,
};