Check for sign problems in compares

git-svn-id: svn://svn.cc65.org/cc65/trunk@932 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2001-09-15 11:51:08 +00:00
parent 02be846175
commit c3cb057407
7 changed files with 11 additions and 7 deletions

View File

@@ -360,7 +360,7 @@ static int FuncStrAt (void)
Index = ConstExpression (); Index = ConstExpression ();
/* Must be a valid index */ /* Must be a valid index */
if (Index >= strlen (Str)) { if (Index >= (long) strlen (Str)) {
Error (ERR_RANGE); Error (ERR_RANGE);
return 0; return 0;
} }

View File

@@ -67,7 +67,7 @@ ListLine* LineLast = 0; /* Last (current) listing line */
/* Page and other formatting */ /* Page and other formatting */
int PageLength = -1; /* Length of a listing page */ int PageLength = -1; /* Length of a listing page */
static unsigned PageNumber = 1; /* Current listing page number */ static unsigned PageNumber = 1; /* Current listing page number */
static unsigned PageLines = 0; /* Current line on page */ static int PageLines = 0; /* Current line on page */
static unsigned ListBytes = 12; /* Number of bytes to list for one line */ static unsigned ListBytes = 12; /* Number of bytes to list for one line */
/* Switch the listing on/off */ /* Switch the listing on/off */

View File

@@ -510,7 +510,7 @@ int main (int argc, char* argv [])
{ "--version", 0, OptVersion }, { "--version", 0, OptVersion },
}; };
int I; unsigned I;
/* Initialize the cmdline module */ /* Initialize the cmdline module */
InitCmdLine (&argc, &argv, "ca65"); InitCmdLine (&argc, &argv, "ca65");
@@ -553,7 +553,7 @@ int main (int argc, char* argv [])
case 'o': case 'o':
OutFile = GetArg (&I, 2); OutFile = GetArg (&I, 2);
break; break;
case 's': case 's':
OptSmart (Arg, 0); OptSmart (Arg, 0);

View File

@@ -5,7 +5,7 @@
# Library dir # Library dir
COMMON = ../common COMMON = ../common
CFLAGS = -g -O2 -Wall -I$(COMMON) CFLAGS = -g -O2 -Wall -Wsign-compare -I$(COMMON)
CC = gcc CC = gcc
EBIND = emxbind EBIND = emxbind
LDFLAGS = LDFLAGS =

View File

@@ -295,7 +295,7 @@ static void FuncRight (void)
List = CollectTokens (0, 9999); List = CollectTokens (0, 9999);
/* Delete tokens from the list until Count tokens are remaining */ /* Delete tokens from the list until Count tokens are remaining */
while (List->Count > Count) { while (List->Count > (unsigned) Count) {
/* Get the first node */ /* Get the first node */
TokNode* T = List->Root; TokNode* T = List->Root;

View File

@@ -687,7 +687,7 @@ Again:
/* Read the number */ /* Read the number */
IVal = 0; IVal = 0;
while (IsDigit (C)) { while (IsDigit (C)) {
if (IVal > (0xFFFFFFFF / 10)) { if (IVal > (long) (0xFFFFFFFFUL / 10)) {
Error (ERR_NUM_OVERFLOW); Error (ERR_NUM_OVERFLOW);
IVal = 0; IVal = 0;
} }

View File

@@ -592,7 +592,11 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio)
SymEntry* S; SymEntry* S;
/* Check the parameters */ /* Check the parameters */
#if (CD_TYPE_MIN != 0)
CHECK (Type >= CD_TYPE_MIN && Type <= CD_TYPE_MAX); CHECK (Type >= CD_TYPE_MIN && Type <= CD_TYPE_MAX);
#else
CHECK (Type <= CD_TYPE_MAX);
#endif
CHECK (Prio >= CD_PRIO_MIN && Prio <= CD_PRIO_MAX); CHECK (Prio >= CD_PRIO_MIN && Prio <= CD_PRIO_MAX);
/* Don't accept local symbols */ /* Don't accept local symbols */