From: cuz Date: Sat, 15 Sep 2001 11:51:08 +0000 (+0000) Subject: Check for sign problems in compares X-Git-Tag: V2.12.0~2650 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c3cb057407ab0502ab612be7642d454095b750dd;p=cc65 Check for sign problems in compares git-svn-id: svn://svn.cc65.org/cc65/trunk@932 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ca65/expr.c b/src/ca65/expr.c index c0d8f8e46..497a6143a 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -360,7 +360,7 @@ static int FuncStrAt (void) Index = ConstExpression (); /* Must be a valid index */ - if (Index >= strlen (Str)) { + if (Index >= (long) strlen (Str)) { Error (ERR_RANGE); return 0; } diff --git a/src/ca65/listing.c b/src/ca65/listing.c index e132b24c3..df256c5a8 100644 --- a/src/ca65/listing.c +++ b/src/ca65/listing.c @@ -67,7 +67,7 @@ ListLine* LineLast = 0; /* Last (current) listing line */ /* Page and other formatting */ int PageLength = -1; /* Length of a listing page */ 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 */ /* Switch the listing on/off */ diff --git a/src/ca65/main.c b/src/ca65/main.c index c86a3332a..6f6784f53 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -510,7 +510,7 @@ int main (int argc, char* argv []) { "--version", 0, OptVersion }, }; - int I; + unsigned I; /* Initialize the cmdline module */ InitCmdLine (&argc, &argv, "ca65"); @@ -553,7 +553,7 @@ int main (int argc, char* argv []) case 'o': OutFile = GetArg (&I, 2); - break; + break; case 's': OptSmart (Arg, 0); diff --git a/src/ca65/make/gcc.mak b/src/ca65/make/gcc.mak index 60b9239cc..788c35338 100644 --- a/src/ca65/make/gcc.mak +++ b/src/ca65/make/gcc.mak @@ -5,7 +5,7 @@ # Library dir COMMON = ../common -CFLAGS = -g -O2 -Wall -I$(COMMON) +CFLAGS = -g -O2 -Wall -Wsign-compare -I$(COMMON) CC = gcc EBIND = emxbind LDFLAGS = diff --git a/src/ca65/nexttok.c b/src/ca65/nexttok.c index 5de8b9cb6..c1a5bb5d3 100644 --- a/src/ca65/nexttok.c +++ b/src/ca65/nexttok.c @@ -295,7 +295,7 @@ static void FuncRight (void) List = CollectTokens (0, 9999); /* Delete tokens from the list until Count tokens are remaining */ - while (List->Count > Count) { + while (List->Count > (unsigned) Count) { /* Get the first node */ TokNode* T = List->Root; diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index c75ec6978..a085068af 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -687,7 +687,7 @@ Again: /* Read the number */ IVal = 0; while (IsDigit (C)) { - if (IVal > (0xFFFFFFFF / 10)) { + if (IVal > (long) (0xFFFFFFFFUL / 10)) { Error (ERR_NUM_OVERFLOW); IVal = 0; } diff --git a/src/ca65/symtab.c b/src/ca65/symtab.c index 7af07dbfe..dc98fe3fa 100644 --- a/src/ca65/symtab.c +++ b/src/ca65/symtab.c @@ -592,7 +592,11 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio) SymEntry* S; /* Check the parameters */ +#if (CD_TYPE_MIN != 0) 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); /* Don't accept local symbols */