From 34597ce6a0420505f27041e75ac138c7cc62523d Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Mon, 3 Feb 2020 23:35:38 +0100 Subject: [PATCH] Mark some section functions as `const` --- include/asm/fstack.h | 2 +- include/asm/section.h | 16 ++++++++-------- src/asm/fstack.c | 2 +- src/asm/section.c | 30 +++++++++++++++--------------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/asm/fstack.h b/include/asm/fstack.h index b71bd718..961583aa 100644 --- a/include/asm/fstack.h +++ b/include/asm/fstack.h @@ -48,7 +48,7 @@ void fstk_DumpStringExpansions(void); void fstk_AddIncludePath(char *s); uint32_t fstk_RunMacro(char *s); void fstk_RunRept(uint32_t count, int32_t nReptLineNo); -FILE *fstk_FindFile(char *fname, char **incPathUsed); +FILE *fstk_FindFile(char const *fname, char **incPathUsed); int32_t fstk_GetLine(void); #endif /* RGBDS_ASM_FSTACK_H */ diff --git a/include/asm/section.h b/include/asm/section.h index d434f27c..d598a9e1 100644 --- a/include/asm/section.h +++ b/include/asm/section.h @@ -18,22 +18,22 @@ struct Section { }; struct Section *out_FindSectionByName(const char *pzName); -void out_NewSection(char *pzName, uint32_t secttype); -void out_NewAbsSection(char *pzName, uint32_t secttype, int32_t org, +void out_NewSection(char const *pzName, uint32_t secttype); +void out_NewAbsSection(char const *pzName, uint32_t secttype, int32_t org, int32_t bank); -void out_NewAlignedSection(char *pzName, uint32_t secttype, int32_t alignment, - int32_t bank); +void out_NewAlignedSection(char const *pzName, uint32_t secttype, + int32_t alignment, int32_t bank); void out_AbsByte(int32_t b); -void out_AbsByteGroup(char *s, int32_t length); +void out_AbsByteGroup(char const *s, int32_t length); void out_Skip(int32_t skip); -void out_String(char *s); +void out_String(char const *s); void out_RelByte(struct Expression *expr); void out_RelWord(struct Expression *expr); void out_RelLong(struct Expression *expr); void out_PCRelByte(struct Expression *expr); -void out_BinaryFile(char *s); -void out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length); +void out_BinaryFile(char const *s); +void out_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length); void out_PushSection(void); void out_PopSection(void); diff --git a/src/asm/fstack.c b/src/asm/fstack.c index 4624b377..7ee2d329 100644 --- a/src/asm/fstack.c +++ b/src/asm/fstack.c @@ -334,7 +334,7 @@ static void printdep(const char *fileName) } } -FILE *fstk_FindFile(char *fname, char **incPathUsed) +FILE *fstk_FindFile(char const *fname, char **incPathUsed) { char path[_MAX_PATH]; int32_t i; diff --git a/src/asm/section.c b/src/asm/section.c index 9ba0d536..a0f047a8 100644 --- a/src/asm/section.c +++ b/src/asm/section.c @@ -82,13 +82,13 @@ struct Section *out_FindSectionByName(const char *pzName) /* * Find a section by name and type. If it doesn't exist, create it */ -static struct Section *findSection(char *pzName, enum SectionType secttype, +static struct Section *findSection(char const *pzName, enum SectionType type, int32_t org, int32_t bank, int32_t alignment) { struct Section *pSect = out_FindSectionByName(pzName); if (pSect) { - if (secttype == pSect->nType + if (type == pSect->nType && ((uint32_t)org) == pSect->nOrg && ((uint32_t)bank) == pSect->nBank && ((uint32_t)alignment == pSect->nAlign)) { @@ -105,10 +105,10 @@ static struct Section *findSection(char *pzName, enum SectionType secttype, if (pSect->pzName == NULL) fatalerror("Not enough memory for sectionname"); - if (nbbanks(secttype) == 1) - bank = bankranges[secttype][0]; + if (nbbanks(type) == 1) + bank = bankranges[type][0]; - pSect->nType = secttype; + pSect->nType = type; pSect->nPC = 0; pSect->nOrg = org; pSect->nBank = bank; @@ -117,10 +117,10 @@ static struct Section *findSection(char *pzName, enum SectionType secttype, pSect->pPatches = NULL; /* It is only needed to allocate memory for ROM sections. */ - if (sect_HasData(secttype)) { + if (sect_HasData(type)) { uint32_t sectsize; - sectsize = maxsize[secttype]; + sectsize = maxsize[type]; pSect->tData = malloc(sectsize); if (pSect->tData == NULL) fatalerror("Not enough memory for section"); @@ -156,7 +156,7 @@ static void setCurrentSection(struct Section *pSect) /* * Set the current section by name and type */ -void out_NewSection(char *pzName, uint32_t secttype) +void out_NewSection(char const *pzName, uint32_t secttype) { setCurrentSection(findSection(pzName, secttype, -1, -1, 1)); } @@ -164,7 +164,7 @@ void out_NewSection(char *pzName, uint32_t secttype) /* * Set the current section by name and type */ -void out_NewAbsSection(char *pzName, uint32_t secttype, int32_t org, +void out_NewAbsSection(char const *pzName, uint32_t secttype, int32_t org, int32_t bank) { setCurrentSection(findSection(pzName, secttype, org, bank, 1)); @@ -173,8 +173,8 @@ void out_NewAbsSection(char *pzName, uint32_t secttype, int32_t org, /* * Set the current section by name and type, using a given byte alignment */ -void out_NewAlignedSection(char *pzName, uint32_t secttype, int32_t alignment, - int32_t bank) +void out_NewAlignedSection(char const *pzName, uint32_t secttype, + int32_t alignment, int32_t bank) { if (alignment < 0 || alignment > 16) yyerror("Alignment must be between 0-16 bits."); @@ -205,7 +205,7 @@ void out_AbsByte(int32_t b) absByteBypassCheck(b); } -void out_AbsByteGroup(char *s, int32_t length) +void out_AbsByteGroup(char const *s, int32_t length) { checkcodesection(); checksectionoverflow(length); @@ -237,7 +237,7 @@ void out_Skip(int32_t skip) /* * Output a NULL terminated string (excluding the NULL-character) */ -void out_String(char *s) +void out_String(char const *s) { checkcodesection(); checksectionoverflow(strlen(s)); @@ -373,7 +373,7 @@ void out_PCRelByte(struct Expression *expr) /* * Output a binary file */ -void out_BinaryFile(char *s) +void out_BinaryFile(char const *s) { FILE *f; @@ -407,7 +407,7 @@ void out_BinaryFile(char *s) fclose(f); } -void out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length) +void out_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length) { FILE *f;