Signed comparison warning fixes.

This commit is contained in:
Fyren 2015-03-06 06:27:37 +00:00
parent 782eee3c58
commit d3da389f9f
16 changed files with 44 additions and 39 deletions

View File

@ -53,7 +53,6 @@ compiler.sourcedeps += packed_includes
if compiler.cc.behavior == 'gcc': if compiler.cc.behavior == 'gcc':
compiler.cflags += ['-Wno-format'] compiler.cflags += ['-Wno-format']
compiler.cflags += ['-Wno-error=sign-compare']
compiler.c_only_flags += ['-std=c99'] compiler.c_only_flags += ['-std=c99']
if builder.target_platform == 'linux': if builder.target_platform == 'linux':
compiler.postlink += ['-lm'] compiler.postlink += ['-lm']

View File

@ -565,12 +565,12 @@ typedef enum s_optmark {
#define suSLEEP_INSTR 0x01 /* the "sleep" instruction was used */ #define suSLEEP_INSTR 0x01 /* the "sleep" instruction was used */
#define FIXEDTAG 0x40000000Lu #define FIXEDTAG 0x40000000
#define FUNCTAG 0x20000000Lu #define FUNCTAG 0x20000000
#define OBJECTTAG 0x10000000Lu #define OBJECTTAG 0x10000000
#define ENUMTAG 0x08000000Lu #define ENUMTAG 0x08000000
#define METHODMAPTAG 0x04000000Lu #define METHODMAPTAG 0x04000000
#define STRUCTTAG 0x02000000Lu #define STRUCTTAG 0x02000000
#define TAGTYPEMASK (FUNCTAG | OBJECTTAG | ENUMTAG | METHODMAPTAG | STRUCTTAG) #define TAGTYPEMASK (FUNCTAG | OBJECTTAG | ENUMTAG | METHODMAPTAG | STRUCTTAG)
#define TAGFLAGMASK (FIXEDTAG | TAGTYPEMASK) #define TAGFLAGMASK (FIXEDTAG | TAGTYPEMASK)
#define TAGID(tag) ((tag) & ~(TAGFLAGMASK)) #define TAGID(tag) ((tag) & ~(TAGFLAGMASK))

View File

@ -150,7 +150,7 @@ int plungequalifiedfile(char *name)
void *fp; void *fp;
char *ext; char *ext;
int ext_idx; size_t ext_idx;
ext_idx=0; ext_idx=0;
do { do {
@ -258,7 +258,8 @@ static void doinclude(int silent)
{ {
char name[_MAX_PATH]; char name[_MAX_PATH];
char c; char c;
int i, result; size_t i;
int result;
while (*lptr<=' ' && *lptr!='\0') /* skip leading whitespace */ while (*lptr<=' ' && *lptr!='\0') /* skip leading whitespace */
lptr++; lptr++;
@ -276,7 +277,7 @@ static void doinclude(int silent)
name[i++]=*lptr++; name[i++]=*lptr++;
while (i>0 && name[i-1]<=' ') while (i>0 && name[i-1]<=' ')
i--; /* strip trailing whitespace */ i--; /* strip trailing whitespace */
assert(i>=0 && i<sizeof name); assert(i<sizeof name);
name[i]='\0'; /* zero-terminate the string */ name[i]='\0'; /* zero-terminate the string */
if (*lptr!=c) { /* verify correct string termination */ if (*lptr!=c) { /* verify correct string termination */
@ -1029,7 +1030,7 @@ static int command(void)
if (*lptr=='"') { if (*lptr=='"') {
lptr=getstring((unsigned char*)name,sizeof name,lptr); lptr=getstring((unsigned char*)name,sizeof name,lptr);
} else { } else {
int i; size_t i;
for (i=0; i<sizeof name && alphanum(*lptr); i++,lptr++) for (i=0; i<sizeof name && alphanum(*lptr); i++,lptr++)
name[i]=*lptr; name[i]=*lptr;
name[i]='\0'; name[i]='\0';
@ -1058,7 +1059,7 @@ static int command(void)
} else if (strcmp(str,"rational")==0) { } else if (strcmp(str,"rational")==0) {
char name[sNAMEMAX+1]; char name[sNAMEMAX+1];
cell digits=0; cell digits=0;
int i; size_t i;
/* first gather all information, start with the tag name */ /* first gather all information, start with the tag name */
while (*lptr<=' ' && *lptr!='\0') while (*lptr<=' ' && *lptr!='\0')
lptr++; lptr++;
@ -1078,9 +1079,9 @@ static int command(void)
lptr++; lptr++;
} /* if */ } /* if */
/* add the tag (make it public) and check the values */ /* add the tag (make it public) and check the values */
i=pc_addtag(name); int tag=pc_addtag(name);
if (sc_rationaltag==0 || (sc_rationaltag==i && rational_digits==(int)digits)) { if (sc_rationaltag==0 || (sc_rationaltag==tag && rational_digits==(int)digits)) {
sc_rationaltag=i; sc_rationaltag=tag;
rational_digits=(int)digits; rational_digits=(int)digits;
} else { } else {
error(69); /* rational number format already set, can only be set once */ error(69); /* rational number format already set, can only be set once */
@ -1107,7 +1108,8 @@ static int command(void)
sc_alignnext=TRUE; sc_alignnext=TRUE;
} else if (strcmp(str,"unused")==0) { } else if (strcmp(str,"unused")==0) {
char name[sNAMEMAX+1]; char name[sNAMEMAX+1];
int i,comma; size_t i;
int comma;
symbol *sym; symbol *sym;
do { do {
/* get the name */ /* get the name */

View File

@ -128,7 +128,8 @@ int check_userop(void (*oper)(void),int tag1,int tag2,int numparam,
static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec }; static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec };
char opername[4] = "", symbolname[sNAMEMAX+1]; char opername[4] = "", symbolname[sNAMEMAX+1];
int i,swapparams,savepri,savealt; size_t i;
int swapparams,savepri,savealt;
int paramspassed; int paramspassed;
symbol *sym; symbol *sym;

View File

@ -365,7 +365,8 @@ void alignframe(int numbytes)
{ {
#if !defined NDEBUG #if !defined NDEBUG
/* "numbytes" should be a power of 2 for this code to work */ /* "numbytes" should be a power of 2 for this code to work */
int i,count=0; size_t i;
int count=0;
for (i=0; i<sizeof numbytes*8; i++) for (i=0; i<sizeof numbytes*8; i++)
if (numbytes & (1 << i)) if (numbytes & (1 << i))
count++; count++;

View File

@ -21,7 +21,7 @@
* Version: $Id$ * Version: $Id$
*/ */
int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2]);
#ifndef SCPACK #ifndef SCPACK
# define SCPACK # define SCPACK

View File

@ -49,7 +49,7 @@
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#define NUM_WARNINGS (sizeof warnmsg / sizeof warnmsg[0]) #define NUM_WARNINGS (int)(sizeof warnmsg / sizeof warnmsg[0])
static unsigned char warndisable[(NUM_WARNINGS + 7) / 8]; /* 8 flags in a char */ static unsigned char warndisable[(NUM_WARNINGS + 7) / 8]; /* 8 flags in a char */
static int errflag; static int errflag;

View File

@ -598,7 +598,7 @@ class VerifyOpcodeSorting
public: public:
VerifyOpcodeSorting() { VerifyOpcodeSorting() {
assert(opcodelist[1].name!=NULL); assert(opcodelist[1].name!=NULL);
for (int i = 2; i<(sizeof opcodelist / sizeof opcodelist[0]); i++) { for (size_t i = 2; i<(sizeof opcodelist / sizeof opcodelist[0]); i++) {
assert(opcodelist[i].name!=NULL); assert(opcodelist[i].name!=NULL);
assert(stricmp(opcodelist[i].name,opcodelist[i-1].name)>0); assert(stricmp(opcodelist[i].name,opcodelist[i-1].name)>0);
} /* for */ } /* for */

View File

@ -22,7 +22,7 @@
* Version: $Id$ * Version: $Id$
*/ */
int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2]);
#define SCPACK_TERMINATOR , /* end each section with a comma */ #define SCPACK_TERMINATOR , /* end each section with a comma */

View File

@ -400,7 +400,7 @@ static SEQUENCE *sequences;
int phopt_init(void) int phopt_init(void)
{ {
int number, i, len; size_t number, i, len;
char str[160]; char str[160];
/* count number of sequences */ /* count number of sequences */
@ -422,13 +422,13 @@ int phopt_init(void)
for (i=0; i<number-1; i++) { for (i=0; i<number-1; i++) {
len = strexpand(str,(unsigned char*)sequences_cmp[i].find,sizeof str,SCPACK_TABLE); len = strexpand(str,(unsigned char*)sequences_cmp[i].find,sizeof str,SCPACK_TABLE);
assert(len<=sizeof str); assert(len<=sizeof str);
assert(len==(int)strlen(str)+1); assert(len==strlen(str)+1);
sequences[i].find=(char*)malloc(len); sequences[i].find=(char*)malloc(len);
if (sequences[i].find!=NULL) if (sequences[i].find!=NULL)
strcpy(sequences[i].find,str); strcpy(sequences[i].find,str);
len = strexpand(str,(unsigned char*)sequences_cmp[i].replace,sizeof str,SCPACK_TABLE); len = strexpand(str,(unsigned char*)sequences_cmp[i].replace,sizeof str,SCPACK_TABLE);
assert(len<=sizeof str); assert(len<=sizeof str);
assert(len==(int)strlen(str)+1); assert(len==strlen(str)+1);
sequences[i].replace=(char*)malloc(len); sequences[i].replace=(char*)malloc(len);
if (sequences[i].replace!=NULL) if (sequences[i].replace!=NULL)
strcpy(sequences[i].replace,str); strcpy(sequences[i].replace,str);

View File

@ -16,11 +16,11 @@
#define STACKSIZE 16 #define STACKSIZE 16
int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]) size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2])
{ {
unsigned char stack[STACKSIZE]; unsigned char stack[STACKSIZE];
short c, top = 0; short c, top = 0;
int len; size_t len;
assert(maxlen > 0); assert(maxlen > 0);
len = 1; /* already 1 byte for '\0' */ len = 1; /* already 1 byte for '\0' */

View File

@ -359,7 +359,7 @@ int delete_subst(char *name,int length)
void delete_substtable(void) void delete_substtable(void)
{ {
int i; size_t i;
delete_stringpairtable(&substpair); delete_stringpairtable(&substpair);
for (i=0; i<sizeof substindex/sizeof substindex[0]; i++) for (i=0; i<sizeof substindex/sizeof substindex[0]; i++)
substindex[i]=NULL; substindex[i]=NULL;

View File

@ -258,9 +258,11 @@ enum OPCODE {
#define _(op, text) OP_##op, #define _(op, text) OP_##op,
OPCODE_LIST(_) OPCODE_LIST(_)
#undef _ #undef _
OPCODES_TOTAL OPCODES_LAST
}; };
#define OPCODES_TOTAL (ucell_t)OPCODES_LAST
} // namespace sp } // namespace sp
#endif // _INCLUDE_SPFILE_HEADERS_v1_opcodes_H #endif // _INCLUDE_SPFILE_HEADERS_v1_opcodes_H

View File

@ -38,7 +38,7 @@ FileReader::FileReader(FILE *fp)
return; return;
ke::AutoArray<uint8_t> bytes(new uint8_t[size]); ke::AutoArray<uint8_t> bytes(new uint8_t[size]);
if (!bytes || fread(bytes, sizeof(uint8_t), size, fp) != size) if (!bytes || fread(bytes, sizeof(uint8_t), size, fp) != (size_t)size)
return; return;
buffer_ = bytes.take(); buffer_ = bytes.take();

View File

@ -21,7 +21,7 @@ using namespace ke;
using namespace sp; using namespace sp;
using namespace SourcePawn; using namespace SourcePawn;
InvokeFrame::InvokeFrame(PluginContext *cx, cell_t entry_cip) InvokeFrame::InvokeFrame(PluginContext *cx, ucell_t entry_cip)
: prev_(Environment::get()->top()), : prev_(Environment::get()->top()),
cx_(cx), cx_(cx),
prev_exit_frame_(Environment::get()->exit_frame()), prev_exit_frame_(Environment::get()->exit_frame()),
@ -82,7 +82,7 @@ FrameIterator::nextInvokeFrame()
assert(sp_stop_ >= sp_iter_); assert(sp_stop_ >= sp_iter_);
runtime_ = ivk_->cx()->runtime(); runtime_ = ivk_->cx()->runtime();
function_cip_ = -1; function_cip_ = kInvalidCip;
pc_ = nullptr; pc_ = nullptr;
cip_ = kInvalidCip; cip_ = kInvalidCip;
@ -170,7 +170,7 @@ FrameIterator::findCip() const
unsigned unsigned
FrameIterator::LineNumber() const FrameIterator::LineNumber() const
{ {
cell_t cip = findCip(); ucell_t cip = findCip();
if (cip == kInvalidCip) if (cip == kInvalidCip)
return 0; return 0;
@ -184,7 +184,7 @@ FrameIterator::LineNumber() const
const char * const char *
FrameIterator::FilePath() const FrameIterator::FilePath() const
{ {
cell_t cip = findCip(); ucell_t cip = findCip();
if (cip == kInvalidCip) if (cip == kInvalidCip)
return runtime_->image()->LookupFile(function_cip_); return runtime_->image()->LookupFile(function_cip_);

View File

@ -64,7 +64,7 @@ class ExitFrame
class InvokeFrame class InvokeFrame
{ {
public: public:
InvokeFrame(PluginContext *cx, cell_t cip); InvokeFrame(PluginContext *cx, ucell_t cip);
~InvokeFrame(); ~InvokeFrame();
InvokeFrame *prev() const { InvokeFrame *prev() const {
@ -80,7 +80,7 @@ class InvokeFrame
const intptr_t *entry_sp() const { const intptr_t *entry_sp() const {
return entry_sp_; return entry_sp_;
} }
cell_t entry_cip() const { ucell_t entry_cip() const {
return entry_cip_; return entry_cip_;
} }
@ -93,7 +93,7 @@ class InvokeFrame
InvokeFrame *prev_; InvokeFrame *prev_;
PluginContext *cx_; PluginContext *cx_;
ExitFrame prev_exit_frame_; ExitFrame prev_exit_frame_;
cell_t entry_cip_; ucell_t entry_cip_;
const intptr_t *entry_sp_; const intptr_t *entry_sp_;
}; };
@ -125,8 +125,8 @@ class FrameIterator : public SourcePawn::IFrameIterator
PluginRuntime *runtime_; PluginRuntime *runtime_;
const intptr_t *sp_iter_; const intptr_t *sp_iter_;
const intptr_t *sp_stop_; const intptr_t *sp_stop_;
cell_t function_cip_; ucell_t function_cip_;
mutable cell_t cip_; mutable ucell_t cip_;
void *pc_; void *pc_;
}; };