diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2016-02-18 02:16:36 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2016-02-18 02:16:36 -0800 |
commit | 7e3b12d6daaa2f9a51115e735c8ccfcb03e5fdbc (patch) | |
tree | 9649650d61139c0f29d8c06eb3cfe79d8fb812f2 | |
parent | f0ea3d7c2b9f3767788fa3945fcdcc8606c0ef69 (diff) | |
download | nasm-7e3b12d6daaa2f9a51115e735c8ccfcb03e5fdbc.tar.gz |
More constification, mostly of struct dfmt
Make struct dfmt and the struct dfmt arrays const across the board,
and make them static whereever possible.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | nasm.h | 2 | ||||
-rw-r--r-- | output/nulldbg.c | 4 | ||||
-rw-r--r-- | output/outcoff.c | 6 | ||||
-rw-r--r-- | output/outdbg.c | 4 | ||||
-rw-r--r-- | output/outelf32.c | 11 | ||||
-rw-r--r-- | output/outelf64.c | 11 | ||||
-rw-r--r-- | output/outelfx32.c | 11 | ||||
-rw-r--r-- | output/outform.c | 16 | ||||
-rw-r--r-- | output/outform.h | 6 | ||||
-rw-r--r-- | output/outieee.c | 4 | ||||
-rw-r--r-- | output/outlib.h | 2 | ||||
-rw-r--r-- | output/outobj.c | 4 |
12 files changed, 44 insertions, 37 deletions
@@ -683,7 +683,7 @@ struct ofmt { /* * this is a pointer to the first element of the debug information */ - struct dfmt **debug_formats; + const struct dfmt * const *debug_formats; /* * the default debugging format if -F is not specified diff --git a/output/nulldbg.c b/output/nulldbg.c index 581a1c55..e8f87d75 100644 --- a/output/nulldbg.c +++ b/output/nulldbg.c @@ -77,7 +77,7 @@ void null_debug_cleanup(void) { } -struct dfmt null_debug_form = { +const struct dfmt null_debug_form = { "Null debug format", "null", null_debug_init, @@ -89,4 +89,4 @@ struct dfmt null_debug_form = { null_debug_cleanup }; -struct dfmt *null_debug_arr[2] = { &null_debug_form, NULL }; +const struct dfmt * const null_debug_arr[2] = { &null_debug_form, NULL }; diff --git a/output/outcoff.c b/output/outcoff.c index e208c93a..3daccb7e 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -1190,11 +1190,11 @@ const struct ofmt of_coff = { #endif -extern struct dfmt df_cv8; +extern const struct dfmt df_cv8; #ifdef OF_WIN32 -struct dfmt *win32_debug_arr[2] = { &df_cv8, NULL }; +static const struct dfmt * const win32_debug_arr[2] = { &df_cv8, NULL }; const struct ofmt of_win32 = { "Microsoft Win32 (i386) object files", @@ -1220,7 +1220,7 @@ const struct ofmt of_win32 = { #ifdef OF_WIN64 -struct dfmt *win64_debug_arr[2] = { &df_cv8, NULL }; +static const struct dfmt * const win64_debug_arr[2] = { &df_cv8, NULL }; const struct ofmt of_win64 = { "Microsoft Win64 (x86-64) object files", diff --git a/output/outdbg.c b/output/outdbg.c index b954f146..fdd80329 100644 --- a/output/outdbg.c +++ b/output/outdbg.c @@ -242,7 +242,7 @@ static void dbgdbg_typevalue(int32_t type) fprintf(ofile, "new type: %s(%"PRIX32")\n", types[TYM_TYPE(type) >> 3], TYM_ELEMENTS(type)); } -static struct dfmt debug_debug_form = { +static const struct dfmt debug_debug_form = { "Trace of all info passed to debug stage", "debug", dbgdbg_init, @@ -254,7 +254,7 @@ static struct dfmt debug_debug_form = { dbgdbg_cleanup, }; -static struct dfmt *debug_debug_arr[3] = { +static const struct dfmt * const debug_debug_arr[3] = { &debug_debug_form, &null_debug_form, NULL diff --git a/output/outelf32.c b/output/outelf32.c index bc8be226..24efc0f5 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -152,8 +152,8 @@ static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, abbrevlen, linelen, linerellen, framelen, loclen; static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; -static struct dfmt df_dwarf; -static struct dfmt df_stabs; +static const struct dfmt df_dwarf; +static const struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ @@ -1335,7 +1335,7 @@ static int elf_set_info(enum geninfo type, char **val) (void)val; return 0; } -static struct dfmt df_dwarf = { +static const struct dfmt df_dwarf = { "ELF32 (i386) dwarf debug format for Linux/Unix", "dwarf", dwarf_init, @@ -1346,7 +1346,7 @@ static struct dfmt df_dwarf = { dwarf_output, dwarf_cleanup }; -static struct dfmt df_stabs = { +static const struct dfmt df_stabs = { "ELF32 (i386) stabs debug format for Linux/Unix", "stabs", null_debug_init, @@ -1358,7 +1358,8 @@ static struct dfmt df_stabs = { stabs_cleanup }; -struct dfmt *elf32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; +static const struct dfmt * const elf32_debugs_arr[3] = + { &df_dwarf, &df_stabs, NULL }; const struct ofmt of_elf32 = { "ELF32 (i386) object files (e.g. Linux)", diff --git a/output/outelf64.c b/output/outelf64.c index dbd0bf05..57be311b 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -154,8 +154,8 @@ static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; -static struct dfmt df_dwarf; -static struct dfmt df_stabs; +static const struct dfmt df_dwarf; +static const struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ @@ -1425,7 +1425,7 @@ static int elf_set_info(enum geninfo type, char **val) (void)val; return 0; } -static struct dfmt df_dwarf = { +static const struct dfmt df_dwarf = { "ELF64 (x86-64) dwarf debug format for Linux/Unix", "dwarf", dwarf_init, @@ -1436,7 +1436,7 @@ static struct dfmt df_dwarf = { dwarf_output, dwarf_cleanup }; -static struct dfmt df_stabs = { +static const struct dfmt df_stabs = { "ELF64 (x86-64) stabs debug format for Linux/Unix", "stabs", null_debug_init, @@ -1448,7 +1448,8 @@ static struct dfmt df_stabs = { stabs_cleanup }; -struct dfmt *elf64_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; +static const struct dfmt * const elf64_debugs_arr[3] = + { &df_dwarf, &df_stabs, NULL }; const struct ofmt of_elf64 = { "ELF64 (x86_64) object files (e.g. Linux)", diff --git a/output/outelfx32.c b/output/outelfx32.c index 0d5edf21..5896af3b 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -154,8 +154,8 @@ static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; -static struct dfmt df_dwarf; -static struct dfmt df_stabs; +static const struct dfmt df_dwarf; +static const struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ @@ -1385,7 +1385,7 @@ static int elf_set_info(enum geninfo type, char **val) (void)val; return 0; } -static struct dfmt df_dwarf = { +static const struct dfmt df_dwarf = { "ELFX32 (x86-64) dwarf debug format for Linux/Unix", "dwarf", dwarf_init, @@ -1396,7 +1396,7 @@ static struct dfmt df_dwarf = { dwarf_output, dwarf_cleanup }; -static struct dfmt df_stabs = { +static const struct dfmt df_stabs = { "ELFX32 (x86-64) stabs debug format for Linux/Unix", "stabs", null_debug_init, @@ -1408,7 +1408,8 @@ static struct dfmt df_stabs = { stabs_cleanup }; -struct dfmt *elfx32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; +static const struct dfmt * const elfx32_debugs_arr[3] = + { &df_dwarf, &df_stabs, NULL }; const struct ofmt of_elfx32 = { "ELFX32 (x86_64) object files (e.g. Linux)", diff --git a/output/outform.c b/output/outform.c index 77983c00..f7c817e7 100644 --- a/output/outform.c +++ b/output/outform.c @@ -47,9 +47,11 @@ #define BUILD_DRIVERS_ARRAY #include "output/outform.h" -const struct ofmt *ofmt_find(char *name, const struct ofmt_alias **ofmt_alias) +const struct ofmt *ofmt_find(const char *name, + const struct ofmt_alias **ofmt_alias) { - const struct ofmt **ofp, *of; + const struct ofmt * const *ofp; + const struct ofmt *of; unsigned int i; *ofmt_alias = NULL; @@ -72,9 +74,10 @@ const struct ofmt *ofmt_find(char *name, const struct ofmt_alias **ofmt_alias) return NULL; } -struct dfmt *dfmt_find(const struct ofmt *ofmt, char *name) +const struct dfmt *dfmt_find(const struct ofmt *ofmt, const char *name) { - struct dfmt **dfp, *df; + const struct dfmt * const *dfp; + const struct dfmt *df; for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) { if (!nasm_stricmp(name, df->shortname)) @@ -85,7 +88,7 @@ struct dfmt *dfmt_find(const struct ofmt *ofmt, char *name) void ofmt_list(const struct ofmt *deffmt, FILE * fp) { - const struct ofmt **ofp, *of; + const struct ofmt * const *ofp, *of; unsigned int i; /* primary targets first */ @@ -107,7 +110,8 @@ void ofmt_list(const struct ofmt *deffmt, FILE * fp) void dfmt_list(const struct ofmt *ofmt, FILE *fp) { - struct dfmt **dfp, *df; + const struct dfmt * const *dfp; + const struct dfmt *df; for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) { fprintf(fp, " %c %-10s%s\n", diff --git a/output/outform.h b/output/outform.h index f01588d0..d2dfef5f 100644 --- a/output/outform.h +++ b/output/outform.h @@ -288,7 +288,7 @@ extern const struct ofmt of_dbg; * drivers array based on the above defines */ -static const struct ofmt *drivers[] = { +static const struct ofmt * const drivers[] = { #ifdef OF_BIN &of_bin, &of_ith, @@ -370,8 +370,8 @@ static const struct ofmt_alias ofmt_aliases[] = { #endif /* BUILD_DRIVERS_ARRAY */ -const struct ofmt *ofmt_find(char *name, const struct ofmt_alias **ofmt_alias); -struct dfmt *dfmt_find(const struct ofmt *, char *); +const struct ofmt *ofmt_find(const char *name, const struct ofmt_alias **ofmt_alias); +const struct dfmt *dfmt_find(const struct ofmt *, const char *); void ofmt_list(const struct ofmt *, FILE *); void dfmt_list(const struct ofmt *ofmt, FILE * fp); extern struct dfmt null_debug_form; diff --git a/output/outieee.c b/output/outieee.c index 727d04ef..e290e038 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -1497,7 +1497,7 @@ static void dbgls_output(int output_type, void *param) (void)output_type; (void)param; } -static struct dfmt ladsoft_debug_form = { +static const struct dfmt ladsoft_debug_form = { "LADsoft Debug Records", "ladsoft", dbgls_init, @@ -1508,7 +1508,7 @@ static struct dfmt ladsoft_debug_form = { dbgls_output, dbgls_cleanup, }; -static struct dfmt *ladsoft_debug_arr[3] = { +static const struct dfmt *ladsoft_debug_arr[3] = { &ladsoft_debug_form, &null_debug_form, NULL diff --git a/output/outlib.h b/output/outlib.h index 1acf11d2..c66dbf6b 100644 --- a/output/outlib.h +++ b/output/outlib.h @@ -53,7 +53,7 @@ void null_debug_directive(const char *directive, const char *params); void null_debug_typevalue(int32_t type); void null_debug_output(int type, void *param); void null_debug_cleanup(void); -extern struct dfmt *null_debug_arr[2]; +extern const struct dfmt * const null_debug_arr[2]; #endif /* NASM_OUTLIB_H */ diff --git a/output/outobj.c b/output/outobj.c index 3cb0610f..f8b35c94 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -2605,7 +2605,7 @@ static void dbgbi_output(int output_type, void *param) (void)output_type; (void)param; } -static struct dfmt borland_debug_form = { +static const struct dfmt borland_debug_form = { "Borland Debug Records", "borland", dbgbi_init, @@ -2617,7 +2617,7 @@ static struct dfmt borland_debug_form = { dbgbi_cleanup, }; -static struct dfmt *borland_debug_arr[3] = { +static const struct dfmt *borland_debug_arr[3] = { &borland_debug_form, &null_debug_form, NULL |