Enable a few warning flags

Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
Antonio Niño Díaz
2018-04-01 02:09:20 +01:00
parent 85ece88268
commit 340362d984
8 changed files with 49 additions and 34 deletions

View File

@@ -28,7 +28,12 @@ VERSION_STRING := `git describe --tags --dirty --always 2>/dev/null`
WARNFLAGS := -Werror -Wall -Wextra -Wpedantic -Wno-sign-compare -Wchkp \
-Wformat=2 -Wformat-overflow=2 -Wformat-truncation=1 \
-Wformat-y2k
-Wformat-y2k -Wswitch-enum -Wunused -Wuninitialized \
-Wunknown-pragmas -Wstrict-overflow=5 -Wstringop-overflow=4 \
-Walloc-zero -Wduplicated-cond -Wfloat-equal -Wshadow \
-Wcast-qual -Wcast-align -Wlogical-op -Wnested-externs \
-Wno-aggressive-loop-optimizations -Winline \
-Wstrict-prototypes -Wold-style-definition
# Overridable CFLAGS
CFLAGS := -g

View File

@@ -414,7 +414,7 @@ void yylex_GetFloatMaskAndFloatLen(uint32_t *pnFloatMask, uint32_t *pnFloatLen)
/*
* Gets the longest keyword/operator from the current position in the buffer.
*/
struct sLexString *yylex_GetLongestFixed()
struct sLexString *yylex_GetLongestFixed(void)
{
struct sLexString *pLongestFixed = NULL;
char *s = pLexBuffer;

View File

@@ -6,6 +6,7 @@
* SPDX-License-Identifier: MIT
*/
#include <float.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
@@ -483,7 +484,7 @@ int main(int argc, char *argv[])
if (CurrentOptions.verbose) {
printf("Success! %u lines in %d.%02d seconds ", nTotalLines,
(int)timespent, ((int)(timespent * 100.0)) % 100);
if (timespent == 0)
if (timespent < FLT_MIN_EXP)
printf("(INFINITY lines/minute)\n");
else
printf("(%d lines/minute)\n",

View File

@@ -469,8 +469,10 @@ struct ColorWithLuminance {
static int compare_luminance(const void *a, const void *b)
{
struct ColorWithLuminance *x = (struct ColorWithLuminance *)a;
struct ColorWithLuminance *y = (struct ColorWithLuminance *)b;
const struct ColorWithLuminance *x, *y;
x = (const struct ColorWithLuminance *)a;
y = (const struct ColorWithLuminance *)b;
return y->luminance - x->luminance;
}

View File

@@ -74,6 +74,10 @@ static void do_max_bank(enum eSectionType Type, int32_t nBank)
if (nBank > MaxVBankUsed)
MaxVBankUsed = nBank;
break;
case SECT_ROM0:
case SECT_WRAM0:
case SECT_OAM:
case SECT_HRAM:
default:
break;
}
@@ -494,7 +498,6 @@ void SetLinkerscriptName(char *tzLinkerscriptFile)
void AssignSections(void)
{
int32_t i;
struct sSection *pSection;
MaxBankUsed = 0;
@@ -503,7 +506,7 @@ void AssignSections(void)
* Initialize the memory areas
*/
for (i = 0; i < BANK_INDEX_MAX; i += 1) {
for (int32_t i = 0; i < BANK_INDEX_MAX; i += 1) {
BankFree[i] = malloc(sizeof(*BankFree[i]));
if (!BankFree[i]) {
@@ -663,6 +666,10 @@ void AssignSections(void)
do_max_bank(pSection->Type, pSection->nBank);
break;
case SECT_ROM0:
case SECT_WRAM0:
case SECT_OAM:
case SECT_HRAM:
default: /* Handle other sections later */
break;
}

View File

@@ -23,7 +23,7 @@
#include "types.h"
extern int yyparse();
extern int yyparse(void);
/* File include stack. */

View File

@@ -14,7 +14,7 @@
#include "link/script.h"
int yylex();
int yylex(void);
void yyerror(char *);
extern int yylineno;
@@ -107,8 +107,8 @@ statement:
%%
extern int yylex();
extern int yyparse();
extern int yylex(void);
extern int yyparse(void);
int yywrap(void)
{

View File

@@ -85,59 +85,59 @@ void script_InitSections(void)
}
}
void script_SetCurrentSectionType(const char *type, uint32_t bank)
void script_SetCurrentSectionType(const char *type, uint32_t bank_num)
{
if (strcmp(type, "ROM0") == 0) {
if (bank != 0)
if (bank_num != 0)
errx(1, "Trying to assign a bank number to ROM0.\n");
current_bank = BANK_INDEX_ROM0;
current_real_bank = 0;
return;
} else if (strcmp(type, "ROMX") == 0) {
if (bank == 0)
if (bank_num == 0)
errx(1, "ROMX index can't be 0.\n");
if (bank > BANK_COUNT_ROMX) {
errx(1, "ROMX index too big (%d > %d).\n", bank,
if (bank_num > BANK_COUNT_ROMX) {
errx(1, "ROMX index too big (%d > %d).\n", bank_num,
BANK_COUNT_ROMX);
}
current_bank = BANK_INDEX_ROMX + bank - 1;
current_real_bank = bank;
current_bank = BANK_INDEX_ROMX + bank_num - 1;
current_real_bank = bank_num;
return;
} else if (strcmp(type, "VRAM") == 0) {
if (bank >= BANK_COUNT_VRAM) {
errx(1, "VRAM index too big (%d >= %d).\n", bank,
if (bank_num >= BANK_COUNT_VRAM) {
errx(1, "VRAM index too big (%d >= %d).\n", bank_num,
BANK_COUNT_VRAM);
}
current_bank = BANK_INDEX_VRAM + bank;
current_real_bank = bank;
current_bank = BANK_INDEX_VRAM + bank_num;
current_real_bank = bank_num;
return;
} else if (strcmp(type, "WRAM0") == 0) {
if (bank != 0)
if (bank_num != 0)
errx(1, "Trying to assign a bank number to WRAM0.\n");
current_bank = BANK_INDEX_WRAM0;
current_real_bank = 0;
return;
} else if (strcmp(type, "WRAMX") == 0) {
if (bank == 0)
if (bank_num == 0)
errx(1, "WRAMX index can't be 0.\n");
if (bank > BANK_COUNT_WRAMX) {
errx(1, "WRAMX index too big (%d > %d).\n", bank,
if (bank_num > BANK_COUNT_WRAMX) {
errx(1, "WRAMX index too big (%d > %d).\n", bank_num,
BANK_COUNT_WRAMX);
}
current_bank = BANK_INDEX_WRAMX + bank - 1;
current_real_bank = bank;
current_bank = BANK_INDEX_WRAMX + bank_num - 1;
current_real_bank = bank_num;
return;
} else if (strcmp(type, "SRAM") == 0) {
if (bank >= BANK_COUNT_SRAM) {
errx(1, "SRAM index too big (%d >= %d).\n", bank,
if (bank_num >= BANK_COUNT_SRAM) {
errx(1, "SRAM index too big (%d >= %d).\n", bank_num,
BANK_COUNT_SRAM);
}
current_bank = BANK_INDEX_SRAM + bank;
current_real_bank = bank;
current_bank = BANK_INDEX_SRAM + bank_num;
current_real_bank = bank_num;
return;
} else if (strcmp(type, "OAM") == 0) {
if (bank != 0) {
if (bank_num != 0) {
errx(1, "%s: Trying to assign a bank number to OAM.\n",
__func__);
}
@@ -145,7 +145,7 @@ void script_SetCurrentSectionType(const char *type, uint32_t bank)
current_real_bank = 0;
return;
} else if (strcmp(type, "HRAM") == 0) {
if (bank != 0) {
if (bank_num != 0) {
errx(1, "%s: Trying to assign a bank number to HRAM.\n",
__func__);
}