shithub: rgbds

Download patch

ref: 2d7d9eef9f26f6cd857d909263f36928aa1a0b7d
parent: a290e19f461700e6449c53fce26865d3d746731e
author: ISSOtm <eldredhabert0@gmail.com>
date: Tue Dec 3 19:16:28 EST 2019

Fix some `make checkcodebase` errors
- Reorder checkpatch ignore flags alphabetically
- Fix checkpatch WARNINGs and CHECKs when they make sense
- Add more checkpatch ignores

--- a/.checkpatch.conf
+++ b/.checkpatch.conf
@@ -28,6 +28,9 @@
 # There's no BIT macro
 --ignore BIT_MACRO
 
+# Don't complain when bools are used in structs
+--ignore BOOL_MEMBER
+
 # Allow CamelCase
 --ignore CAMELCASE
 
@@ -40,6 +43,10 @@
 # Don't complain about structs not being const
 --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
 --ignore GIT_COMMIT_ID
 
@@ -46,6 +53,9 @@
 # Do not check for global initializers (this is specific to the kernel)
 --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.
 --ignore FILE_PATH_CHANGES
 
@@ -56,9 +66,15 @@
 # have a really long line that can be found with grep.
 --ignore LONG_LINE_STRING
 
+# Don't complain when files are modified in 'include/asm'
+--ignore MODIFIED_INCLUDE_ASM
+
 # Allow 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
 --ignore PREFER_KERNEL_TYPES
 
@@ -67,12 +83,3 @@
 
 # Parentheses can make the code clearer
 --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
--- a/include/asm/charmap.h
+++ b/include/asm/charmap.h
@@ -20,8 +20,10 @@
  */
 struct Charnode {
 	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. */
-	struct Charnode *next[256]; /* each index representing the next possible character from its current state. */
+	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 Charmap {
@@ -28,7 +30,9 @@
 	char name[MAXSYMLEN + 1];
 	int32_t charCount; /* user-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 */
 };
 
--- a/include/asm/symbol.h
+++ b/include/asm/symbol.h
@@ -25,7 +25,7 @@
 	struct Section *pSection;
 	uint32_t ulMacroSize;
 	char *pMacro;
-	int32_t (*Callback)(struct sSymbol *);
+	int32_t (*Callback)(struct sSymbol *self);
 	char tzFileName[_MAX_PATH + 1]; /* File where the symbol was defined. */
 	uint32_t nFileLine; /* Line where the symbol was defined. */
 };
--- a/include/link/main.h
+++ b/include/link/main.h
@@ -38,7 +38,7 @@
  * @param mode The mode to open the file with
  * @return A pointer to a valid FILE structure, or NULL if fileName was NULL
  */
-FILE *openFile(char const *fileName, char const *mode);
+FILE * openFile(char const *fileName, char const *mode);
 
 #define closeFile(file) do { \
 				FILE *tmp = file; \
--- a/include/link/script.h
+++ b/include/link/script.h
@@ -12,7 +12,7 @@
 
 #include <stdint.h>
 
-extern FILE *linkerScript;
+extern FILE * linkerScript;
 
 struct SectionPlacement {
 	struct Section *section;
--- a/src/asm/charmap.c
+++ b/src/asm/charmap.c
@@ -163,8 +163,8 @@
 	int32_t i;
 	uint8_t v;
 
-	struct Charmap 	*charmap;
-	struct Charnode	*curr_node, *temp_node;
+	struct Charmap  *charmap;
+	struct Charnode *curr_node, *temp_node;
 
 	/*
 	 * If the user tries to define a character mapping inside a section
@@ -217,8 +217,8 @@
 
 int32_t charmap_Convert(char **input)
 {
-	struct Charmap 	*charmap;
-	struct Charnode	*charnode;
+	struct Charmap  *charmap;
+	struct Charnode *charnode;
 
 	char *output;
 	char outchar[8];
@@ -249,11 +249,11 @@
 		charnode = &charmap->nodes[0];
 
 		/*
-		 * find the longest valid match which has been registered in charmap.
-		 * note that there could be either multiple matches or no match.
-		 * and it possibly takes the longest match between them,
-		 * which means that it ignores partial matches shorter than the longest one.
-		*/
+		 * Find the longest valid match which has been registered in
+		 * charmap, possibly yielding multiple or no matches.
+		 * The longest match is taken, meaning partial matches shorter
+		 * than the longest one are ignored.
+		 */
 		for (i = match = 0; (v = (*input)[i]);) {
 			if (!charnode->next[v])
 				break;
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -317,7 +317,8 @@
 	if (NextIncPath == MAXINCPATHS)
 		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);
 }
 
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -1029,6 +1029,7 @@
 int yylex(void)
 {
 	int returnedChar;
+
 	switch (lexerstate) {
 	case LEX_STATE_NORMAL:
 		returnedChar = yylex_NORMAL();
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -265,13 +265,12 @@
 	uint32_t offset;
 	int32_t sectid;
 
-	if (!(pSym->nType & SYMF_DEFINED)) {
+	if (!(pSym->nType & SYMF_DEFINED))
 		type = SYMTYPE_IMPORT;
-	} else if (pSym->nType & SYMF_EXPORT) {
+	else if (pSym->nType & SYMF_EXPORT)
 		type = SYMTYPE_EXPORT;
-	} else {
+	else
 		type = SYMTYPE_LOCAL;
-	}
 
 	switch (type) {
 	case SYMTYPE_LOCAL:
--- a/src/gfx/gb.c
+++ b/src/gfx/gb.c
@@ -199,7 +199,6 @@
 		attrmap->size = 0;
 	}
 
-
 	gb_i = 0;
 	while (gb_i < gb_size) {
 		flags = 0;
@@ -210,8 +209,10 @@
 		}
 		if (opts->unique) {
 			if (opts->mirror) {
-				index = get_mirrored_tile_index(tile, tiles, num_tiles,
-								tile_size, &flags);
+				index = get_mirrored_tile_index(tile, tiles,
+								num_tiles,
+								tile_size,
+								&flags);
 			} else {
 				index = get_tile_index(tile, tiles, num_tiles,
 						       tile_size);
--- a/src/gfx/main.c
+++ b/src/gfx/main.c
@@ -68,7 +68,6 @@
 	struct Mapfile tilemap = {0};
 	struct Mapfile attrmap = {0};
 	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)
 		print_usage();
@@ -149,6 +148,10 @@
 	if (argc == 0)
 		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];
 
 	if (depth != 1 && depth != 2)
@@ -164,7 +167,7 @@
 
 	if (png_options.horizontal != opts.horizontal) {
 		if (opts.verbose)
-			warnx(errmsg, "horizontal");
+			WARN_MISMATCH("horizontal");
 
 		if (opts.hardfix)
 			png_options.horizontal = opts.horizontal;
@@ -175,7 +178,7 @@
 
 	if (png_options.trim != opts.trim) {
 		if (opts.verbose)
-			warnx(errmsg, "trim");
+			WARN_MISMATCH("trim");
 
 		if (opts.hardfix)
 			png_options.trim = opts.trim;
@@ -202,7 +205,7 @@
 
 	if (strcmp(png_options.tilemapfile, opts.tilemapfile) != 0) {
 		if (opts.verbose)
-			warnx(errmsg, "tilemap file");
+			WARN_MISMATCH("tilemap file");
 
 		if (opts.hardfix)
 			png_options.tilemapfile = opts.tilemapfile;
@@ -212,7 +215,7 @@
 
 	if (png_options.tilemapout != opts.tilemapout) {
 		if (opts.verbose)
-			warnx(errmsg, "tilemap file");
+			WARN_MISMATCH("tilemap file");
 
 		if (opts.hardfix)
 			png_options.tilemapout = opts.tilemapout;
@@ -222,7 +225,7 @@
 
 	if (strcmp(png_options.attrmapfile, opts.attrmapfile) != 0) {
 		if (opts.verbose)
-			warnx(errmsg, "attrmap file");
+			WARN_MISMATCH("attrmap file");
 
 		if (opts.hardfix)
 			png_options.attrmapfile = opts.attrmapfile;
@@ -232,7 +235,7 @@
 
 	if (png_options.attrmapout != opts.attrmapout) {
 		if (opts.verbose)
-			warnx(errmsg, "attrmap file");
+			WARN_MISMATCH("attrmap file");
 
 		if (opts.hardfix)
 			png_options.attrmapout = opts.attrmapout;
@@ -242,7 +245,7 @@
 
 	if (strcmp(png_options.palfile, opts.palfile) != 0) {
 		if (opts.verbose)
-			warnx(errmsg, "palette file");
+			WARN_MISMATCH("palette file");
 
 		if (opts.hardfix)
 			png_options.palfile = opts.palfile;
@@ -252,11 +255,13 @@
 
 	if (png_options.palout != opts.palout) {
 		if (opts.verbose)
-			warnx(errmsg, "palette file");
+			WARN_MISMATCH("palette file");
 
 		if (opts.hardfix)
 			png_options.palout = opts.palout;
 	}
+
+#undef WARN_MISMATCH
 
 	if (png_options.palout)
 		opts.palout = png_options.palout;
--- a/src/gfx/makepng.c
+++ b/src/gfx/makepng.c
@@ -13,7 +13,7 @@
 
 #include "gfx/main.h"
 
-static void initialize_png(struct PNGImage *img, FILE *f);
+static void initialize_png(struct PNGImage *img, FILE * f);
 static struct RawIndexedImage *indexed_png_to_raw(struct PNGImage *img);
 static struct RawIndexedImage *grayscale_png_to_raw(struct PNGImage *img);
 static struct RawIndexedImage *truecolor_png_to_raw(struct PNGImage *img);
--- a/src/link/output.c
+++ b/src/link/output.c
@@ -9,7 +9,7 @@
 
 #include "extern/err.h"
 
-FILE *outputFile;
+FILE * outputFile;
 FILE *overlayFile;
 FILE *symFile;
 FILE *mapFile;
@@ -357,9 +357,8 @@
 	symFile = openFile(symFileName, "w");
 	mapFile = openFile(mapFileName, "w");
 
-	if (symFileName) {
+	if (symFileName)
 		fputs("; File generated by rgblink\n", symFile);
-	}
 
 	for (uint8_t i = 0; i < SECTTYPE_INVALID; i++) {
 		enum SectionType type = typeMap[i];
--- a/src/link/script.c
+++ b/src/link/script.c
@@ -11,7 +11,7 @@
 
 #include "extern/err.h"
 
-FILE *linkerScript;
+FILE * linkerScript;
 
 static uint32_t lineNo;