Fix some make checkcodebase errors

- Reorder checkpatch ignore flags alphabetically
- Fix checkpatch WARNINGs and CHECKs when they make sense
- Add more checkpatch ignores
This commit is contained in:
ISSOtm
2019-12-04 00:16:28 +01:00
parent a290e19f46
commit 2d7d9eef9f
14 changed files with 63 additions and 46 deletions

View File

@@ -28,6 +28,9 @@
# There's no BIT macro # There's no BIT macro
--ignore BIT_MACRO --ignore BIT_MACRO
# Don't complain when bools are used in structs
--ignore BOOL_MEMBER
# Allow CamelCase # Allow CamelCase
--ignore CAMELCASE --ignore CAMELCASE
@@ -40,12 +43,19 @@
# Don't complain about structs not being const # Don't complain about structs not being const
--ignore CONST_STRUCT --ignore CONST_STRUCT
# Don't complain about printing "warning:" without the function name, as warning
# printing is relevant to the code being parsed, not RGBDS' code
--ignore EMBEDDED_FUNCTION_NAME
# Do not check the format of commit messages # Do not check the format of commit messages
--ignore GIT_COMMIT_ID --ignore GIT_COMMIT_ID
# Do not check for global initializers (this is specific to the kernel) # Do not check for global initializers (this is specific to the kernel)
--ignore GLOBAL_INITIALISERS --ignore GLOBAL_INITIALISERS
# Don't complain about initializing statics (this is specific to the kernel)
--ignore INITIALISED_STATIC
# We don't have a MAINTAINERS file, don't complain about it. # We don't have a MAINTAINERS file, don't complain about it.
--ignore FILE_PATH_CHANGES --ignore FILE_PATH_CHANGES
@@ -56,9 +66,15 @@
# have a really long line that can be found with grep. # have a really long line that can be found with grep.
--ignore LONG_LINE_STRING --ignore LONG_LINE_STRING
# Don't complain when files are modified in 'include/asm'
--ignore MODIFIED_INCLUDE_ASM
# Allow new typedefs # Allow new typedefs
--ignore NEW_TYPEDEFS --ignore NEW_TYPEDEFS
# We allow lines ending with parentheses for the usage prints
--ignore OPEN_ENDED_LINE
# Prefer stdint.h types over kernel types # Prefer stdint.h types over kernel types
--ignore PREFER_KERNEL_TYPES --ignore PREFER_KERNEL_TYPES
@@ -67,12 +83,3 @@
# Parentheses can make the code clearer # Parentheses can make the code clearer
--ignore UNNECESSARY_PARENTHESES --ignore UNNECESSARY_PARENTHESES
# Don't complain when files are modified in 'include/asm'
--ignore MODIFIED_INCLUDE_ASM
# Don't complain when bools are used in structs
--ignore BOOL_MEMBER
# Don't complain about initializing statics (this is specific to the kernel)
--ignore INITIALISED_STATIC

View File

@@ -20,15 +20,19 @@
*/ */
struct Charnode { struct Charnode {
uint8_t code; /* the value in a key-value pair. */ uint8_t code; /* the value in a key-value pair. */
uint8_t isCode; /* has one if it's a code node, not just a bridge node. */ uint8_t isCode; /* has 1 if it's a code node, not just a bridge node. */
struct Charnode *next[256]; /* each index representing the next possible character from its current state. */ struct Charnode *next[256]; /* each index representing the next possible
* character from its current state.
*/
}; };
struct Charmap { struct Charmap {
char name[MAXSYMLEN + 1]; char name[MAXSYMLEN + 1];
int32_t charCount; /* user-side count. */ int32_t charCount; /* user-side count. */
int32_t nodeCount; /* node-side count. */ int32_t nodeCount; /* node-side count. */
struct Charnode nodes[MAXCHARNODES]; /* first node is reserved for the root node in charmap. */ struct Charnode nodes[MAXCHARNODES]; /* first node is reserved for the
* root node in charmap.
*/
struct Charmap *next; /* next charmap in hash table bucket */ struct Charmap *next; /* next charmap in hash table bucket */
}; };

View File

@@ -25,7 +25,7 @@ struct sSymbol {
struct Section *pSection; struct Section *pSection;
uint32_t ulMacroSize; uint32_t ulMacroSize;
char *pMacro; char *pMacro;
int32_t (*Callback)(struct sSymbol *); int32_t (*Callback)(struct sSymbol *self);
char tzFileName[_MAX_PATH + 1]; /* File where the symbol was defined. */ char tzFileName[_MAX_PATH + 1]; /* File where the symbol was defined. */
uint32_t nFileLine; /* Line where the symbol was defined. */ uint32_t nFileLine; /* Line where the symbol was defined. */
}; };

View File

@@ -249,10 +249,10 @@ int32_t charmap_Convert(char **input)
charnode = &charmap->nodes[0]; charnode = &charmap->nodes[0];
/* /*
* find the longest valid match which has been registered in charmap. * Find the longest valid match which has been registered in
* note that there could be either multiple matches or no match. * charmap, possibly yielding multiple or no matches.
* and it possibly takes the longest match between them, * The longest match is taken, meaning partial matches shorter
* which means that it ignores partial matches shorter than the longest one. * than the longest one are ignored.
*/ */
for (i = match = 0; (v = (*input)[i]);) { for (i = match = 0; (v = (*input)[i]);) {
if (!charnode->next[v]) if (!charnode->next[v])

View File

@@ -317,7 +317,8 @@ void fstk_AddIncludePath(char *s)
if (NextIncPath == MAXINCPATHS) if (NextIncPath == MAXINCPATHS)
fatalerror("Too many include directories passed from command line"); fatalerror("Too many include directories passed from command line");
if (snprintf(IncludePaths[NextIncPath++], _MAX_PATH, "%s", s) >= _MAX_PATH) if (snprintf(IncludePaths[NextIncPath++], _MAX_PATH, "%s",
s) >= _MAX_PATH)
fatalerror("Include path too long '%s'", s); fatalerror("Include path too long '%s'", s);
} }

View File

@@ -1029,6 +1029,7 @@ static uint32_t yylex_MACROARGS(void)
int yylex(void) int yylex(void)
{ {
int returnedChar; int returnedChar;
switch (lexerstate) { switch (lexerstate) {
case LEX_STATE_NORMAL: case LEX_STATE_NORMAL:
returnedChar = yylex_NORMAL(); returnedChar = yylex_NORMAL();

View File

@@ -265,13 +265,12 @@ static void writesymbol(struct sSymbol *pSym, FILE *f)
uint32_t offset; uint32_t offset;
int32_t sectid; int32_t sectid;
if (!(pSym->nType & SYMF_DEFINED)) { if (!(pSym->nType & SYMF_DEFINED))
type = SYMTYPE_IMPORT; type = SYMTYPE_IMPORT;
} else if (pSym->nType & SYMF_EXPORT) { else if (pSym->nType & SYMF_EXPORT)
type = SYMTYPE_EXPORT; type = SYMTYPE_EXPORT;
} else { else
type = SYMTYPE_LOCAL; type = SYMTYPE_LOCAL;
}
switch (type) { switch (type) {
case SYMTYPE_LOCAL: case SYMTYPE_LOCAL:

View File

@@ -199,7 +199,6 @@ void create_mapfiles(const struct Options *opts, struct GBImage *gb,
attrmap->size = 0; attrmap->size = 0;
} }
gb_i = 0; gb_i = 0;
while (gb_i < gb_size) { while (gb_i < gb_size) {
flags = 0; flags = 0;
@@ -210,8 +209,10 @@ void create_mapfiles(const struct Options *opts, struct GBImage *gb,
} }
if (opts->unique) { if (opts->unique) {
if (opts->mirror) { if (opts->mirror) {
index = get_mirrored_tile_index(tile, tiles, num_tiles, index = get_mirrored_tile_index(tile, tiles,
tile_size, &flags); num_tiles,
tile_size,
&flags);
} else { } else {
index = get_tile_index(tile, tiles, num_tiles, index = get_tile_index(tile, tiles, num_tiles,
tile_size); tile_size);

View File

@@ -68,7 +68,6 @@ int main(int argc, char *argv[])
struct Mapfile tilemap = {0}; struct Mapfile tilemap = {0};
struct Mapfile attrmap = {0}; struct Mapfile attrmap = {0};
char *ext; char *ext;
const char *errmsg = "Warning: The PNG's %s setting is not the same as the setting defined on the command line.";
if (argc == 1) if (argc == 1)
print_usage(); print_usage();
@@ -149,6 +148,10 @@ int main(int argc, char *argv[])
if (argc == 0) if (argc == 0)
print_usage(); print_usage();
#define WARN_MISMATCH(property) \
warnx("The PNG's " property \
" setting doesn't match the one defined on the command line")
opts.infile = argv[argc - 1]; opts.infile = argv[argc - 1];
if (depth != 1 && depth != 2) if (depth != 1 && depth != 2)
@@ -164,7 +167,7 @@ int main(int argc, char *argv[])
if (png_options.horizontal != opts.horizontal) { if (png_options.horizontal != opts.horizontal) {
if (opts.verbose) if (opts.verbose)
warnx(errmsg, "horizontal"); WARN_MISMATCH("horizontal");
if (opts.hardfix) if (opts.hardfix)
png_options.horizontal = opts.horizontal; png_options.horizontal = opts.horizontal;
@@ -175,7 +178,7 @@ int main(int argc, char *argv[])
if (png_options.trim != opts.trim) { if (png_options.trim != opts.trim) {
if (opts.verbose) if (opts.verbose)
warnx(errmsg, "trim"); WARN_MISMATCH("trim");
if (opts.hardfix) if (opts.hardfix)
png_options.trim = opts.trim; png_options.trim = opts.trim;
@@ -202,7 +205,7 @@ int main(int argc, char *argv[])
if (strcmp(png_options.tilemapfile, opts.tilemapfile) != 0) { if (strcmp(png_options.tilemapfile, opts.tilemapfile) != 0) {
if (opts.verbose) if (opts.verbose)
warnx(errmsg, "tilemap file"); WARN_MISMATCH("tilemap file");
if (opts.hardfix) if (opts.hardfix)
png_options.tilemapfile = opts.tilemapfile; png_options.tilemapfile = opts.tilemapfile;
@@ -212,7 +215,7 @@ int main(int argc, char *argv[])
if (png_options.tilemapout != opts.tilemapout) { if (png_options.tilemapout != opts.tilemapout) {
if (opts.verbose) if (opts.verbose)
warnx(errmsg, "tilemap file"); WARN_MISMATCH("tilemap file");
if (opts.hardfix) if (opts.hardfix)
png_options.tilemapout = opts.tilemapout; png_options.tilemapout = opts.tilemapout;
@@ -222,7 +225,7 @@ int main(int argc, char *argv[])
if (strcmp(png_options.attrmapfile, opts.attrmapfile) != 0) { if (strcmp(png_options.attrmapfile, opts.attrmapfile) != 0) {
if (opts.verbose) if (opts.verbose)
warnx(errmsg, "attrmap file"); WARN_MISMATCH("attrmap file");
if (opts.hardfix) if (opts.hardfix)
png_options.attrmapfile = opts.attrmapfile; png_options.attrmapfile = opts.attrmapfile;
@@ -232,7 +235,7 @@ int main(int argc, char *argv[])
if (png_options.attrmapout != opts.attrmapout) { if (png_options.attrmapout != opts.attrmapout) {
if (opts.verbose) if (opts.verbose)
warnx(errmsg, "attrmap file"); WARN_MISMATCH("attrmap file");
if (opts.hardfix) if (opts.hardfix)
png_options.attrmapout = opts.attrmapout; png_options.attrmapout = opts.attrmapout;
@@ -242,7 +245,7 @@ int main(int argc, char *argv[])
if (strcmp(png_options.palfile, opts.palfile) != 0) { if (strcmp(png_options.palfile, opts.palfile) != 0) {
if (opts.verbose) if (opts.verbose)
warnx(errmsg, "palette file"); WARN_MISMATCH("palette file");
if (opts.hardfix) if (opts.hardfix)
png_options.palfile = opts.palfile; png_options.palfile = opts.palfile;
@@ -252,12 +255,14 @@ int main(int argc, char *argv[])
if (png_options.palout != opts.palout) { if (png_options.palout != opts.palout) {
if (opts.verbose) if (opts.verbose)
warnx(errmsg, "palette file"); WARN_MISMATCH("palette file");
if (opts.hardfix) if (opts.hardfix)
png_options.palout = opts.palout; png_options.palout = opts.palout;
} }
#undef WARN_MISMATCH
if (png_options.palout) if (png_options.palout)
opts.palout = png_options.palout; opts.palout = png_options.palout;

View File

@@ -357,9 +357,8 @@ static void writeSymAndMap(void)
symFile = openFile(symFileName, "w"); symFile = openFile(symFileName, "w");
mapFile = openFile(mapFileName, "w"); mapFile = openFile(mapFileName, "w");
if (symFileName) { if (symFileName)
fputs("; File generated by rgblink\n", symFile); fputs("; File generated by rgblink\n", symFile);
}
for (uint8_t i = 0; i < SECTTYPE_INVALID; i++) { for (uint8_t i = 0; i < SECTTYPE_INVALID; i++) {
enum SectionType type = typeMap[i]; enum SectionType type = typeMap[i];