shithub: rgbds

Download patch

ref: 3fb5648880bccdd52b627c137d18710b687d8e1f
parent: a7c0616cd8f2e2f141e0d7233702bb5516c09031
author: ISSOtm <[email protected]>
date: Tue Jan 21 06:37:30 EST 2020

Actually rely on `createsymbol` never returning NULL
This reduces complexity, basically

--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -493,12 +493,10 @@
 {
 	struct sSymbol *nsym = createNonrelocSymbol(tzSym);
 
-	if (nsym) {
-		nsym->nValue = value;
-		nsym->nType |= SYMF_EQU | SYMF_DEFINED | SYMF_CONST;
-		nsym->pScope = NULL;
-		updateSymbolFilename(nsym);
-	}
+	nsym->nValue = value;
+	nsym->nType |= SYMF_EQU | SYMF_DEFINED | SYMF_CONST;
+	nsym->pScope = NULL;
+	updateSymbolFilename(nsym);
 }
 
 /*
@@ -517,18 +515,16 @@
 {
 	struct sSymbol *nsym = createNonrelocSymbol(tzSym);
 
-	if (nsym) {
-		nsym->pMacro = malloc(strlen(tzValue) + 1);
+	nsym->pMacro = malloc(strlen(tzValue) + 1);
 
-		if (nsym->pMacro != NULL)
-			strcpy(nsym->pMacro, tzValue);
-		else
-			fatalerror("No memory for string equate");
+	if (nsym->pMacro != NULL)
+		strcpy(nsym->pMacro, tzValue);
+	else
+		fatalerror("No memory for string equate");
 
-		nsym->nType |= SYMF_STRING | SYMF_DEFINED;
-		nsym->ulMacroSize = strlen(tzValue);
-		nsym->pScope = NULL;
-	}
+	nsym->nType |= SYMF_STRING | SYMF_DEFINED;
+	nsym->ulMacroSize = strlen(tzValue);
+	nsym->pScope = NULL;
 }
 
 /*
@@ -570,12 +566,10 @@
 		nsym = createsymbol(tzSym);
 	}
 
-	if (nsym) {
-		nsym->nValue = value;
-		nsym->nType |= SYMF_SET | SYMF_DEFINED | SYMF_CONST;
-		nsym->pScope = NULL;
-		updateSymbolFilename(nsym);
-	}
+	nsym->nValue = value;
+	nsym->nType |= SYMF_SET | SYMF_DEFINED | SYMF_CONST;
+	nsym->pScope = NULL;
+	updateSymbolFilename(nsym);
 }
 
 /*
@@ -634,24 +628,22 @@
 		nsym = createsymbol(tzSym);
 	}
 
-	if (nsym) {
-		nsym->nValue = nPC;
-		nsym->nType |= SYMF_RELOC | SYMF_DEFINED;
-		if (localPtr)
-			nsym->nType |= SYMF_LOCAL;
+	nsym->nValue = nPC;
+	nsym->nType |= SYMF_RELOC | SYMF_DEFINED;
+	if (localPtr)
+		nsym->nType |= SYMF_LOCAL;
 
-		if (exportall)
-			nsym->nType |= SYMF_EXPORT;
+	if (exportall)
+		nsym->nType |= SYMF_EXPORT;
 
-		nsym->pScope = scope;
-		nsym->pSection = pCurrentSection;
-		/* Labels need to be assigned a section, except PC */
-		if (!pCurrentSection && strcmp(tzSym, "@"))
-			yyerror("Label \"%s\" created outside of a SECTION",
-				tzSym);
+	nsym->pScope = scope;
+	nsym->pSection = pCurrentSection;
+	/* Labels need to be assigned a section, except PC */
+	if (!pCurrentSection && strcmp(tzSym, "@"))
+		yyerror("Label \"%s\" created outside of a SECTION",
+			tzSym);
 
-		updateSymbolFilename(nsym);
-	}
+	updateSymbolFilename(nsym);
 
 	pScope = findsymbol(tzSym, scope);
 }
@@ -713,8 +705,7 @@
 	if (nsym == NULL)
 		nsym = createsymbol(tzSym);
 
-	if (nsym)
-		nsym->nType |= SYMF_EXPORT;
+	nsym->nType |= SYMF_EXPORT;
 }
 
 /*
@@ -724,18 +715,16 @@
 {
 	struct sSymbol *nsym = createNonrelocSymbol(tzSym);
 
-	if (nsym) {
-		nsym->nType |= SYMF_MACRO | SYMF_DEFINED;
-		nsym->pScope = NULL;
-		nsym->ulMacroSize = ulNewMacroSize;
-		nsym->pMacro = tzNewMacro;
-		updateSymbolFilename(nsym);
-		/*
-		 * The symbol is created at the line after the `endm`,
-		 * override this with the actual definition line
-		 */
-		nsym->nFileLine = nDefLineNo;
-	}
+	nsym->nType |= SYMF_MACRO | SYMF_DEFINED;
+	nsym->pScope = NULL;
+	nsym->ulMacroSize = ulNewMacroSize;
+	nsym->pMacro = tzNewMacro;
+	updateSymbolFilename(nsym);
+	/*
+	 * The symbol is created at the line after the `endm`,
+	 * override this with the actual definition line
+	 */
+	nsym->nFileLine = nDefLineNo;
 }
 
 /*
@@ -762,12 +751,11 @@
 
 		nsym = createsymbol(tzSym);
 
-		if (nsym && isLocal)
+		if (isLocal)
 			nsym->nType |= SYMF_LOCAL;
 	}
 
-	if (nsym)
-		nsym->nType |= SYMF_REF;
+	nsym->nType |= SYMF_REF;
 }
 
 /*