From ba9666525f68ab75a7176bd02b7e8d0dc8c644b7 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 27 Jun 2021 01:26:30 -0400 Subject: sim: model: constify sim_machs storage The array of pointers is never modified, so mark it const so it ends up in the read-only data section. --- sim/common/ChangeLog | 9 +++++++++ sim/common/sim-model.c | 10 +++++----- sim/common/sim-model.h | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'sim/common') diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 6926fd3..7b21b00 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,5 +1,14 @@ 2021-06-29 Mike Frysinger + * sim-model.c (model_option_handler): Make machp const. + (sim_model_lookup): Likewise. + (sim_mach_lookup): Likewise. + (sim_mach_lookup_bfd_name): Likewise. + (sim_machs): Add const. + * sim-model.h (sim_machs): Likewise. + +2021-06-29 Mike Frysinger + * sim-io.h (sim_io_vprintf): Add ATTRIBUTE_PRINTF. (sim_io_evprintf): Likewise. diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c index e1af9d4..bfdb3c2 100644 --- a/sim/common/sim-model.c +++ b/sim/common/sim-model.c @@ -74,7 +74,7 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt, case OPTION_MODEL_INFO : { - const SIM_MACH **machp; + const SIM_MACH * const *machp; const SIM_MODEL *model; for (machp = & sim_machs[0]; *machp != NULL; ++machp) { @@ -140,7 +140,7 @@ sim_model_set (SIM_DESC sd, sim_cpu *cpu, const SIM_MODEL *model) const SIM_MODEL * sim_model_lookup (const char *name) { - const SIM_MACH **machp; + const SIM_MACH * const *machp; const SIM_MODEL *model; for (machp = & sim_machs[0]; *machp != NULL; ++machp) @@ -160,7 +160,7 @@ sim_model_lookup (const char *name) const SIM_MACH * sim_mach_lookup (const char *name) { - const SIM_MACH **machp; + const SIM_MACH * const *machp; for (machp = & sim_machs[0]; *machp != NULL; ++machp) { @@ -176,7 +176,7 @@ sim_mach_lookup (const char *name) const SIM_MACH * sim_mach_lookup_bfd_name (const char *name) { - const SIM_MACH **machp; + const SIM_MACH * const *machp; for (machp = & sim_machs[0]; *machp != NULL; ++machp) { @@ -251,7 +251,7 @@ sim_model_init (SIM_DESC sd) #if !WITH_MODEL_P /* Set up basic model support. This is a stub for ports that do not define models. See sim-model.h for more details. */ -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { NULL }; diff --git a/sim/common/sim-model.h b/sim/common/sim-model.h index 3a028d5..d6edf64 100644 --- a/sim/common/sim-model.h +++ b/sim/common/sim-model.h @@ -140,7 +140,7 @@ typedef struct model { /* ??? In a simulator of multiple architectures, will need multiple copies of this. Have an `archs' array that contains a pointer to the machs array for each (which in turn has a pointer to the models array for each). */ -extern const SIM_MACH *sim_machs[]; +extern const SIM_MACH * const sim_machs[]; /* Model module handlers. */ extern MODULE_INSTALL_FN sim_model_install; -- cgit v1.1